Cannot read selected organization after login pops up the picker

I spent more than 3 days researching this and testing, but I cannot find an answer, and I am not sure it could actually work.

We want to start using organizations. I enabled 2 organizations for my test user, and now, I can see the organizations picker after user/password. In theory, when I pick the organization, it should come in the token as a claim.

The tokens never carry the organization id. I tried to insert the data myself in the post-login trigger. Every other information is carried except for organizations. I have different post-login actions and they work perfectly, for example, we receive if the policies have been accepted from the metadata:

metadata.privacy_policies

The “Add Organization” action does not yield the information. It seems the data is overridden after I try to set it

    api.idToken.setCustomClaim(

      "https://cats.dev-thepioneers.com/organizations",

      {

        pioneers_org_id: event.organization.id,

        pioneers_org_name: event.organization.name,

      }

    );    

Any other claim works, except for organization information. But I think something is cleared up in the process for organizations only, the log shows me that the data was set (at least the data was valid) in the Successful login event, but a second event (that I don’t understand why it happens) named “Successful Silent Login” does not have the data anymore.

I tried several solutions online, such as reading the organization data in the React hook, but there is no event ever that contains that information. We have nothing in between, the Auth0Provider in React does all the work.

I can add any extra information required in order to understand the issue.