App icon indicating copy to clipboard operation
App copied to clipboard

[$175] Workflows - Missing hint and role not disabled for Authorized Payer

Open applause-bot[bot] opened this issue 2 months ago • 38 comments

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: v9.4.94-0 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/75704622/folder/53678307/48358512/1798307301?sort=%2Bidentifier Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Regression TC Execution Device used: Windows 10/Chrome App Component: Workspace Settings

Action Performed:

Preconditions Preconditions The user is in a workspace with a connected bank account The workspace has fewer than 8 members with admin role

  1. Navigate to the workspace from preconditions > Workflows
  2. Click on the Payer field to open the Authorized Payer RHP
  3. Set any of the admin as the Payer (Don't select owner) - Click Share
  4. Go to the Members tab
  5. Click on the Admin payer member to view the member detail page
  6. Verify that the role field is disabled and a hint text below it saying: "Role can't be changed because this member is a [payer] on this workspace.

Expected Result:

Verify that the role field is disabled and a hint text below it saying: "Role can't be changed because this member is a [payer] on this workspace.

Actual Result:

Missing hint and role not disabled for Authorized Payer

Workaround:

Unknown

Platforms:

  • [x] Android: App
  • [ ] Android: mWeb Chrome
  • [x] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [x] Windows: Chrome
  • [ ] MacOS: Chrome Safari

Screenshots/Videos

https://github.com/user-attachments/assets/5531be52-7743-47be-a973-0f9a78b21188

View all open jobs on GitHub

Applause Internal Information Exported by: Julia Ponikarchuk Bug ID: 7270566

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @jasperhuangg

applause-bot[bot] avatar Sep 28 '26 07:09 applause-bot[bot]

While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/9fd6c007d5ed6c118d414f783d87cdf2d4b14395c8f6d91e204a6b6911d4d878

applause-bot[bot] avatar Sep 28 '26 07:09 applause-bot[bot]

Proposal

What is the root cause of that problem?

This is mostly intended behavior, and the test case is out of date. Allow promoting the Authorized Payer to Workspace Admin (merged 2026-08-27) deliberately removed the blanket lock and the "Role can't be changed…" hint. That PR fixed Authorized Payer cannot be promoted to Workspace Admin because the Role field is locked. A later revert, Revert #98123 to resolve Authorized Payer deploy blockers, was closed without merging.

The payer's Role row now stays editable when there is another payer role they can switch to. The role picker then offers only payer roles. As a result, common.roleCannotBeChanged is no longer used anywhere.

There is one real gap. PAYER_ROLES includes Editor, but the role picker never offers Editor. On a Collect workspace, an admin payer's Role row looks editable because of Editor. The picker then shows only "Workspace admin", the role they already have. So the row is a dead end, and the lock hint never shows.

Code references

What changes do you think we should make in order to solve the problem?

  1. Update the regression test case. On a Control workspace, an admin payer can switch between Workspace Admin and Payments Admin, so the Role row should stay enabled with no hint.
  2. In WorkspaceMemberDetailsPage, count only the payer roles the picker actually offers when you compute canReimburserChangeRole. In practice, leave out Editor.
  3. When the payer has no other role to switch to, disable the row and show common.roleCannotBeChanged with a link to the Workflows payments page. Bring back the useEnvironment URL and shouldRenderHintAsHTML that #98123 removed.
  4. Change the Collect test above so it expects a disabled row with the hint.

What alternative solutions did you explore? (Optional)

If product wants the old blanket lock back, restore !isReimburser in canEditSelectedMemberRole and the hint. That reverts #98123, which the team already declined.

Open question: I couldn't confirm which roles the backend accepts for the payer, especially Editor. That decides whether Editor should also be removed from PAYER_ROLES.


Next Steps for Contributor+ team: To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/102392) to create a draft PR. To refine: @MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.


view run

MelvinBot avatar Sep 28 '26 07:09 MelvinBot

Triggered auto assignment to Contributor-plus team member for initial proposal review - @getusha (External)

melvin-bot[bot] avatar Sep 28 '26 07:09 melvin-bot[bot]

Job added to Upwork: https://www.upwork.com/jobs/~022104469819161590429

melvin-bot[bot] avatar Sep 28 '26 07:09 melvin-bot[bot]

## Proposal

Please re-state the problem that we are trying to solve in this issue.

In Workspace Settings > Members, when an Admin is set as the Authorized Payer on a Collect workspace (or any workspace where no other payer role is assignable), the Role field remains interactive instead of being disabled, and the expected hint text "Role can't be changed because this member is a [payer] on this workspace" is completely missing. When tapping on the row, the role selector page opens as a dead end, offering only the role they already hold (Workspace Admin).


What is the root cause of that problem?

There are two distinct root causes introduced in PR #98123 (Allow promoting the Authorized Payer to Workspace Admin):

  1. The Phantom Role CONST.POLICY.ROLE.EDITOR in PAYER_ROLES: In src/libs/PolicyUtils.ts (lines 704–711):

    function canRolePay(role: string | undefined): boolean {
        return !!role && ROLE_PERMISSION_BUNDLES[role]?.[CONST.POLICY.POLICY_FEATURE.WORKFLOWS_PAYMENTS] === CONST.POLICY.POLICY_FEATURE_ACCESS.WRITE;
    }
    
    const PAYER_ROLES = Object.values(CONST.POLICY.ROLE).filter(canRolePay);
    

    Because EDITOR_POLICY_FEATURES grants WRITE access to all features except ASSIGN_ELEVATED_ROLES, canRolePay(CONST.POLICY.ROLE.EDITOR) evaluates to true, including editor inside PAYER_ROLES.

    However, CONST.POLICY.ROLE.EDITOR is an internal/non-UI role that is never offered in src/components/WorkspaceMemberRoleList.tsx (the UI only renders ADMIN, AUDITOR, CARD_ADMIN, PEOPLE_ADMIN, PAYMENTS_ADMIN, and USER).

    In src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx (lines 160–162):

    const assignablePayerRoles = PAYER_ROLES.filter((payerRole) => canMemberAssignRole(policy, currentUserLogin, payerRole));
    const canReimburserChangeRole = assignablePayerRoles.some((payerRole) => payerRole !== member?.role);
    const canEditSelectedMemberRole = !isSelectedMemberOwner && !isSelectedMemberCurrentUser && canManageSelectedMemberRole && (!isReimburser || canReimburserChangeRole);
    

    isControlPolicyOnlyRole('editor') returns false (it is not in CONTROL_POLICY_ONLY_ROLES). Therefore, for an Admin user on a Collect policy, canMemberAssignRole(policy, currentUserLogin, CONST.POLICY.ROLE.EDITOR) returns true. Consequently, assignablePayerRoles contains ['admin', 'editor']. When checking if an Admin payer can change roles: canReimburserChangeRole evaluates assignablePayerRoles.some((payerRole) => payerRole !== member?.role), which returns true because 'editor' !== 'admin'! This causes canEditSelectedMemberRole to evaluate to true on Collect workspaces even though there are no other payer roles actually selectable in the UI.

  2. Complete Removal of hintText and shouldRenderHintAsHTML from MenuItemWithTopDescription: In PR #98123, lines 401–402 were unconditionally removed from WorkspaceMemberDetailsPage.tsx:

    - hintText={isReimburser ? translate('common.roleCannotBeChanged', workspaceWorkflowsPageURL) : undefined}
    - shouldRenderHintAsHTML
    

    Even when canEditSelectedMemberRole is false, MenuItemWithTopDescription receives no hintText at all. The translation string common.roleCannotBeChanged ("Role can't be changed because this member is a <link>payer</link> on this workspace.") is never rendered.


What changes do you think we should make in order to solve the problem?

  1. Filter PAYER_ROLES to Only Active Selectable Roles in src/libs/PolicyUtils.ts: Filter out CONST.POLICY.ROLE.EDITOR from PAYER_ROLES (or define PAYER_ROLES to strictly include roles that are valid for selection in WorkspaceMemberRoleList: ADMIN and PAYMENTS_ADMIN):

    const PAYER_ROLES = Object.values(CONST.POLICY.ROLE)
        .filter((role) => role !== CONST.POLICY.ROLE.EDITOR)
        .filter(canRolePay);
    

    (On Collect policies, payments_admin is filtered out by canMemberAssignRole because it is in CONTROL_POLICY_ONLY_ROLES. Thus, for an Admin payer on Collect, assignablePayerRoles will contain only ['admin'], correctly causing canReimburserChangeRole to be false).

  2. Restore the Dynamic hintText in src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx:

    • Re-introduce useEnvironment:
      const {environmentURL} = useEnvironment();
      const workspaceWorkflowsPageURL = `${environmentURL}/${ROUTES.WORKSPACE_WORKFLOWS.getRoute(policyID, CONST.TAB.WORKFLOWS.PAYMENTS)}`;
      
    • When the member is the Authorized Payer and cannot change roles (isReimburser && !canReimburserChangeRole), render the explanatory hint with the workflow payments link:
      <MenuItemWithTopDescription
          disabled={!canEditSelectedMemberRole}
          title={translate(`workspace.common.roleName`, member?.role)}
          interactive={canEditSelectedMemberRole}
          description={translate('common.role')}
          shouldShowRightIcon={canEditSelectedMemberRole}
          shouldGreyOutWhenDisabled={false}
          shouldUseDefaultCursorWhenDisabled
          hintText={isReimburser && !canReimburserChangeRole ? translate('common.roleCannotBeChanged', workspaceWorkflowsPageURL) : undefined}
          shouldRenderHintAsHTML
          pressableTestID="member-role-menu-item"
          onPress={() => {
              ...
          }}
      />
      
  3. Automated Unit Tests: Update tests/ui/WorkspaceMemberDetailsPageTest.tsx and tests/ui/WorkspaceMembersTest.tsx:

    • Verify that on a Collect workspace with an Admin Authorized Payer, the role field is disabled and displays the common.roleCannotBeChanged hint with the correct URL.
    • Verify that on a Control workspace, an Admin Authorized Payer can switch to Payments Admin, so the role field remains interactive and does not display the hint.

What alternative solutions did you explore? (Optional)

  • Reverting PR #98123 entirely: Rejected because PR #98123 was specifically merged to allow promoting/changing Authorized Payers to Payments Admin on Control workspaces without needing to unassign them first. Our solution preserves that intended capability while properly fixing the Collect workspace boundary and restoring the disabled hint.
  • Adding EDITOR to CONTROL_POLICY_ONLY_ROLES: Rejected because EDITOR is not a Control-tier role; it is an internal permission bundle that shouldn't leak into payer role eligibility.

Contributor details: Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~014b4243d3d5732b2e

naufalfx805-source avatar Sep 28 '26 12:09 naufalfx805-source

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~014b4243d3d5732b2e

naufalfx805-source avatar Sep 28 '26 12:09 naufalfx805-source

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Sep 28 '26 12:09 melvin-bot[bot]

Proposal

Please re-state the problem that we are trying to solve in this issue.

In Workspace Settings > Members, when an Admin is designated as the Authorized Payer on a Collect workspace (or any workspace where no other payer role is assignable), the Role field remains interactive instead of disabled, and the expected hint text "Role can't be changed because this member is a [payer] on this workspace" is completely missing. Tapping on the row navigates to a dead-end role selection page that only offers the role they already hold (Workspace Admin).


What is the root cause of that problem?

There are two root causes introduced in PR #98123 (Allow promoting the Authorized Payer to Workspace Admin):

  1. Inclusion of Non-UI Role CONST.POLICY.ROLE.EDITOR in PAYER_ROLES: In src/libs/PolicyUtils.ts (lines 704–711):

    function canRolePay(role: string | undefined): boolean {
        return !!role && ROLE_PERMISSION_BUNDLES[role]?.[CONST.POLICY.POLICY_FEATURE.WORKFLOWS_PAYMENTS] === CONST.POLICY.POLICY_FEATURE_ACCESS.WRITE;
    }
    
    const PAYER_ROLES = Object.values(CONST.POLICY.ROLE).filter(canRolePay);
    

    Because EDITOR_POLICY_FEATURES has WRITE access to WORKFLOWS_PAYMENTS, canRolePay(CONST.POLICY.ROLE.EDITOR) evaluates to true, including editor in PAYER_ROLES. However, editor is an internal permission bundle that is never offered in WorkspaceMemberRoleList.tsx.

    In src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx (lines 160–162):

    const assignablePayerRoles = PAYER_ROLES.filter((payerRole) => canMemberAssignRole(policy, currentUserLogin, payerRole));
    const canReimburserChangeRole = assignablePayerRoles.some((payerRole) => payerRole !== member?.role);
    const canEditSelectedMemberRole = !isSelectedMemberOwner && !isSelectedMemberCurrentUser && canManageSelectedMemberRole && (!isReimburser || canReimburserChangeRole);
    

    For an Admin on a Collect policy, canMemberAssignRole(policy, currentUserLogin, CONST.POLICY.ROLE.EDITOR) returns true (it is not in CONTROL_POLICY_ONLY_ROLES). Thus, assignablePayerRoles contains ['admin', 'editor']. canReimburserChangeRole evaluates assignablePayerRoles.some((payerRole) => payerRole !== member?.role), which evaluates to true because 'editor' !== 'admin'! This causes canEditSelectedMemberRole to evaluate to true on Collect workspaces even though no other payer roles are actually available.

  2. Omission of hintText and shouldRenderHintAsHTML from MenuItemWithTopDescription: In PR #98123, the hint rendering on the role menu item was removed. Even when canEditSelectedMemberRole is false, the explanatory hint text common.roleCannotBeChanged ("Role can't be changed because this member is a payer on this workspace.") is never rendered.


What changes do you think we should make in order to solve the problem?

  1. In src/libs/PolicyUtils.ts: Filter out CONST.POLICY.ROLE.EDITOR from PAYER_ROLES so that only user-facing selectable roles are considered:

    --- a/src/libs/PolicyUtils.ts
    +++ b/src/libs/PolicyUtils.ts
    @@ -707,7 +707,9 @@ function canRolePay(role: string | undefined): boolean {
         return !!role && ROLE_PERMISSION_BUNDLES[role]?.[CONST.POLICY.POLICY_FEATURE.WORKFLOWS_PAYMENTS] === CONST.POLICY.POLICY_FEATURE_ACCESS.WRITE;
     }
    
    -const PAYER_ROLES = Object.values(CONST.POLICY.ROLE).filter(canRolePay);
    +const PAYER_ROLES = Object.values(CONST.POLICY.ROLE)
    +    .filter((role) => role !== CONST.POLICY.ROLE.EDITOR)
    +    .filter(canRolePay);
    
  2. In src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx:

    • Re-introduce useEnvironment:
      const {environmentURL} = useEnvironment();
      const workspaceWorkflowsPageURL = `${environmentURL}/${ROUTES.WORKSPACE_WORKFLOWS.getRoute(policyID, CONST.TAB.WORKFLOWS.PAYMENTS)}`;
      
    • Restore the explanatory hint text when the member is an Authorized Payer who cannot change roles:
      <MenuItemWithTopDescription
          disabled={!canEditSelectedMemberRole}
          title={translate(`workspace.common.roleName`, member?.role)}
          interactive={canEditSelectedMemberRole}
          description={translate('common.role')}
          shouldShowRightIcon={canEditSelectedMemberRole}
          shouldGreyOutWhenDisabled={false}
          shouldUseDefaultCursorWhenDisabled
          hintText={isReimburser && !canReimburserChangeRole ? translate('common.roleCannotBeChanged', workspaceWorkflowsPageURL) : undefined}
          shouldRenderHintAsHTML
          pressableTestID="member-role-menu-item"
          onPress={() => {
              ...
          }}
      />
      

Automated Unit Tests:

In tests/ui/WorkspaceMemberDetailsPageTest.tsx:

  • Test 1: On a Collect workspace where an Admin is the Authorized Payer, assert that the role menu item is disabled and renders the common.roleCannotBeChanged hint text containing the workflow payments URL.
  • Test 2: On a Control workspace where an Admin is the Authorized Payer, assert that the role menu item remains interactive and does not render the disabled hint text (allowing transition to Payments Admin).

What alternative solutions did you explore? (Optional)

  • Reverting PR #98123: Rejected because PR #98123 enables promoting Authorized Payers to Payments Admin on Control workspaces without requiring unassigning them first. Our targeted fix preserves that capability while correctly handling the Collect workspace boundary.

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0139ed4098bdc50182

bonnhatnguyen avatar Sep 29 '26 21:09 bonnhatnguyen

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Sep 29 '26 21:09 melvin-bot[bot]

@getusha Whoops! This issue is 2 days overdue. Let's get this updated quick!

melvin-bot[bot] avatar Oct 01 '26 21:10 melvin-bot[bot]

Withdrawing my proposal on this issue to comply with Expensify's one-job-at-a-time policy for new contributors. Thanks to the team!

naufalfx805-source avatar Oct 03 '26 04:10 naufalfx805-source

@getusha Still overdue 6 days?! Let's take care of this!

melvin-bot[bot] avatar Oct 05 '26 22:10 melvin-bot[bot]

@getusha Now this issue is 8 days overdue. Are you sure this should be a Daily? Feel free to change it!

melvin-bot[bot] avatar Oct 07 '26 21:10 melvin-bot[bot]

@getusha 10 days overdue. Is anyone even seeing these? Hello?

melvin-bot[bot] avatar Oct 09 '26 21:10 melvin-bot[bot]

@getusha this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

melvin-bot[bot] avatar Oct 12 '26 21:10 melvin-bot[bot]

This issue has not been updated in over 14 days. @getusha eroding to Weekly issue.

melvin-bot[bot] avatar Oct 14 '26 21:10 melvin-bot[bot]

@getusha this issue is now 4 weeks old, please consider:

  • Finding a contributor to fix the bug
  • Closing the issue if BZ has been unable to add the issue to a VIP or Wave project
  • If you have any questions, don't hesitate to start a discussion in #expensify-open-source

Thanks!

melvin-bot[bot] avatar Oct 26 '26 21:10 melvin-bot[bot]

@getusha Huh... This is 4 days overdue. Who can take care of this?

melvin-bot[bot] avatar Nov 03 '26 03:11 melvin-bot[bot]

@getusha Eep! 4 days overdue now. Issues have feelings too...

melvin-bot[bot] avatar Nov 03 '26 09:11 melvin-bot[bot]

@MelvinBot analyze and propose again since your proposal might be outdated.

getusha avatar Nov 03 '26 14:11 getusha