How do I migrate Auth0 rules to actions

I am currently trying to migrate our Auth0 rule to actions. When I take a simple rule that successfully adds a custom role to the token and migrate it to an action the role doesnt show up in the token.

Rule

function (user, context, callback) { if (context.clientName === 'MyClientName') {
  var namespace = 'https://ournamespace.com/';
  var roles = [];

roles.push('testRole');

if (context.accessToken) {  
  context.accessToken[namespace + 'email'] = user.email;
  context.accessToken[namespace + 'scopes'] = roles.join(' ');
}
  
  try {
    user.team_scopes = roles.join(' ');
  } catch (e) {
    console.log(e);
  }
  
  callback(null, user, context);
} else { callback(null, user, context); } }

Result

{
  "name": "My Name",
  "email": "[email protected]",
  "team_scopes": "testRole",
  "iss": "****",
  "sub": "****",
  "aud": "****",
  "iat": ****,
  "exp": ****
}

Action

exports.onExecutePostLogin = async (event, api) => {
  const namespace = 'https://ournamespace.com/';
  let roles = [];
  roles.push('TestRole');
  console.log(`Adding roles to token: ${roles.join(' ')}`);
  api.accessToken.setCustomClaim(`${namespace}team_scopes`, roles.join(' '));
};

Result

{
  "name": "My Name",
  "email": "[email protected]",
  "iss": "****",
  "sub": "****",
  "aud": "****",
  "iat": ****,
  "exp": ****
}

I’ve tried disabling the rule so only the action is there.
The rule and action are named the same.
it almost seems like the action isnt being triggered because when I run it from the Auth0 UI and I seem to get the expected result.

Please help me understand what I’m doing wrong.