Skip to content

[$175] Workflow - Removing approver from workspace does not replace them with the WS owner #102687

Closed

Description

@applause-bot

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


Version Number: 9.4.99-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/76328606/folder/57610124/41236922/1811656195
Email or phone of affected tester (no customers): applausetester+bm890333@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Web, android
App Component: Workspace Settings

Action Performed:

Precondition -
Use Expensifail account.
Workspace is created, with a few members added.

  1. Go to staging.new.expensify.com
  2. Go to Workflows and create a new approval workflow with a submitter and approver.
  3. Go to Members and remove the approver from the workspace.
  4. Go back to the workflow.

Expected Result:

Approver should be replaced by the workspace owner in the workflow after being removed.

Actual Result:

Approver is not replaced by the workspace owner in the workflow after being removed.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome Safari

Screenshots/Videos

Bug7273789_1790791455457.bandicam_2026-09-30_20-50-47-155.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Svetlana Lazutkina
Bug ID: 7273789

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

Activity

  1. added
    Daily
    Bug
    on Sep 30, 2026
  2. applause-bot commented on Sep 30, 2026

    @applause-bot
    Author

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

  3. MelvinBot commented on Sep 30, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    With the multipleApprovers beta on, approval workflows are saved as approval rules, and the Workflows page reads approvers from those rules. The two member-removal pages were never updated for rules. They still look for approvers only in employeeList (submitsTo / forwardsTo), and they only send employeeList-based updates. So the rule that sends the submitter to the removed approver is never changed, and the workflow keeps showing the removed approver instead of the owner.

    This gap came in with [Payment due @thelullabyy] Allow setting and displaying approval workflows with the new structure. That PR added the rules-based create and display paths but not the member-removal path.

    Code references

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

    When the multipleApprovers beta is on, update removeUsers in WorkspaceMembersPage and removeUser in WorkspaceMemberDetailsPage to work with rules:

    1. Build the workflows from the policy's rules with convertApprovalWorkflowRulesToWorkflows, the same way the Workflows tab does.
    2. Treat a member as an approver if isPolicyApprover is true or they appear as an approver in any rule-based workflow. Use the same check for the "approver will be replaced by the owner" confirmation.
    3. Run the existing updateWorkflowDataOnApproverRemoval. Save each changed workflow with updateApprovalWorkflowRules, or with removeApprovalWorkflowRules when the workflow should be removed. Skip unchanged workflows.
    4. Match original and updated workflows by approver or members, not by index, because the helper can drop workflows. Pass the updated rules from one call to the next so edits to shared rules don't overwrite each other.
    5. Add unit tests for removing an approver of a non-default rule-based workflow from both pages.
    Open questions
    • I haven't confirmed that the Applause account has the multipleApprovers beta. Without the beta, the legacy path removes the custom workflow and moves the submitter to the owner's default workflow. If the tester had the beta off, "not replaced" may just mean the workflow disappeared.
    • I couldn't reproduce this on web because the test environment's sign-in hung.
    • Backend behavior isn't visible from App. If DeleteMembersFromWorkspace should also clean up rules that point to a removed member, that change is outside the App repo and needs an internal engineer.

    What alternative solutions did you explore? (Optional)

    The backend could rewrite any rules that point to the removed approver when it processes DeleteMembersFromWorkspace. That would cover every client, but it needs backend work outside the App repo.

    Related issues

    These open issues describe similar problems:


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


    view run · view recording

  4. added
    External
    on Sep 30, 2026
  5. melvin-bot commented on Sep 30, 2026

    @melvin-bot

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

  6. changed the title [-]Workflow - Removing approver from workspace does not replace them with the WS owner[/-] [+][$175] Workflow - Removing approver from workspace does not replace them with the WS owner[/+] on Sep 30, 2026
  7. melvin-bot commented on Sep 30, 2026

    @melvin-bot
  8. bonnhatnguyen commented on Sep 30, 2026

    @bonnhatnguyen

    Proposal

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

    In a workspace with the multipleApprovers beta enabled (or when using rule-based approval workflows), when an admin removes a member who is assigned as an approver from the workspace (either via the Members page bulk action or the Member Details page), the removed approver is not replaced with the workspace owner in the approval workflows. The Workflows page continues to display the removed member as the approver.


    What is the root cause of that problem?

    Member removal in both WorkspaceMembersPage.tsx and WorkspaceMemberDetailsPage.tsx relies exclusively on legacy employeeList helpers rather than rule-based workflows:

    1. isPolicyApprover ignores rule-based workflows:
      In src/libs/PolicyUtils.ts (lines 821–828):

      function isPolicyApprover(policy: OnyxInputOrEntry<Policy>, employeeLogin: string) {
          if (policy?.approver === employeeLogin) {
              return true;
          }
          return Object.values(policy?.employeeList ?? {}).some(
              (employee) => employee?.submitsTo === employeeLogin || employee?.forwardsTo === employeeLogin || employee?.overLimitForwardsTo === employeeLogin,
          );
      }

      isPolicyApprover only checks policy.approver and policy.employeeList. In rule-based approval workflows, routing is stored in approval rules under ONYXKEYS.COLLECTION.RULE (policy.rules), where rule.approver holds the approver's email. Consequently, isPolicyApprover returns false for approvers configured through rules.

    2. Member removal early-returns and bypasses workflow updates:
      In WorkspaceMemberDetailsPage.tsx (lines 243–247):

      if (!isPolicyApprover(policy, memberLogin) || !removedApprover?.login || !ownerEmail) {
          removeMemberAndCloseModal();
          return;
      }

      Because isPolicyApprover returns false, removeUser immediately proceeds to removeMemberAndCloseModal() without reassigning the workflow to the workspace owner. Similarly, in WorkspaceMembersPage.tsx (lines 237–239), hasApprovers evaluates to false, skipping updateWorkflowDataOnApproverRemoval.

    3. Approval workflows are converted from legacy employeeList instead of rules:
      In both pages:

      const {approvalWorkflows} = convertPolicyEmployeesToApprovalWorkflows({
          policy,
          personalDetails: personalDetails ?? {},
          localeCompare,
          currentUserLogin,
      });

      Even if the check passed, approvalWorkflows is generated from convertPolicyEmployeesToApprovalWorkflows rather than checking isMultipleApproversBetaEnabled and using convertApprovalWorkflowRulesToWorkflows (as done in WorkflowsApprovalsTab.tsx).


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

    1. In src/libs/PolicyUtils.ts:
      Update isPolicyApprover to also inspect rule-based approval workflows when rules are present:

      function isPolicyApprover(policy: OnyxInputOrEntry<Policy>, employeeLogin: string, rules?: OnyxCollection<Rule>) {
          if (policy?.approver === employeeLogin) {
              return true;
          }
          const hasEmployeeListApprover = Object.values(policy?.employeeList ?? {}).some(
              (employee) => employee?.submitsTo === employeeLogin || employee?.forwardsTo === employeeLogin || employee?.overLimitForwardsTo === employeeLogin,
          );
          if (hasEmployeeListApprover) {
              return true;
          }
          if (rules && policy?.id) {
              const policyRules = getApprovalWorkflowRulesForPolicy(rules, policy.id);
              return Object.values(policyRules).some((rule) => rule?.approver === employeeLogin);
          }
          return false;
      }
    2. In src/pages/workspace/WorkspaceMembersPage.tsx and src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx:

      • Subscribe to ONYXKEYS.COLLECTION.RULE.
      • When isMultipleApproversBetaEnabled is true, derive approvalWorkflows using convertApprovalWorkflowRulesToWorkflows({rules, policy, personalDetails, localeCompare}), matching WorkflowsApprovalsTab.tsx.
      • In removeUsers / removeUser, pass rules to isPolicyApprover.
      • When an approver is removed under isMultipleApproversBetaEnabled, execute updateApprovalWorkflow or setApprovalWorkflowRules using the updated workflow diff so that rules pointing to the removed approver are updated to the workspace owner (ownerDetails.login).
    3. Add Unit Tests:

      • Add test coverage in tests/unit/PolicyUtilsTest.ts verifying that isPolicyApprover returns true when a user is an approver in rule-based workflow rules.
      • Add test coverage in tests/actions/PolicyTest.ts verifying that removing a member who is an approver replaces them with the workspace owner in both legacy and rule-based workflows.

    What alternative solutions did you explore? (Optional)

    Handling rule cleanup purely on the backend during DeleteMembersFromWorkspace. While the backend should ideally maintain referential integrity, NewDot uses optimistic Onyx updates and client-side workflow transitions (such as setApprovalWorkflowRules and updateApprovalWorkflow). Relying solely on the backend leaves the client UI in an inconsistent state until a full refresh occurs, which contradicts the immediate optimistic feedback standard in Expensify App.

  9. camesenin commented on Sep 30, 2026

    @camesenin
  10. melvin-bot commented on Sep 30, 2026

    @melvin-bot

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

  11. ikevin127 commented on Oct 1, 2026

    @ikevin127
    Contributor

    @MelvinBot I tried reproducing, here's what happened on my side - 2 scenarios:

    • with all betas enabled: the actual issue's expected result happens - workspace owner becomes approver when the approver of the added workflow approval is removed as member from WS
    • without all betas enabled (just default new private domain account fresh sign-up): the actual result differs for me - when the approver of the added workflow approval is removed as member from WS, that added workflow approval is removed / goes away leaving me with only the original approval workflow that was already there on a new account

    What do you suggest in this case ? Given your proposal on this issue which doesn't seem accurate given my reproduction.

  12. MelvinBot commented on Oct 1, 2026

    @MelvinBot
    Contributor

    You're right. My proposal doesn't hold up against your reproduction, so I'm withdrawing it. Both of your results match how the code is designed to work. I suggest closing this issue as expected behavior unless Applause can show a case that breaks it.

    Without the beta, removing the workflow is intended. When the removed approver is the only approver of a non-default workflow, and the owner already approves the default workflow, the code removes that workflow. Its members go back to the default workflow, where the owner approves their reports. The code replaces the approver with the owner only when the default workflow's approver is someone other than the owner. On a new workspace the owner is the default approver, so the workflow goes away. That is what you saw, and what the Applause tester most likely read as "not replaced."

    With all betas on, you saw the expected result. That means the rules-based gap I described doesn't reproduce.

    Code and tests
    • Removal logic for a workflow with one approver: WorkflowUtils.ts:598-629. If defaultHasOwner is true, it returns removeApprovalWorkflow: true. Otherwise it puts the owner in place of the removed approver.
    • Unit tests that cover both cases: WorkflowUtilsTest.ts:1086-1139. One test removes the workflow when the owner approves the default workflow. Another replaces the approver with the owner when the default approver is someone else.

    It's only a bug if one of these is true. Applause can check both:

    1. The default workflow's approver was not the owner, and the custom workflow still disappeared or kept the removed approver.
    2. After the removal, the submitter's new reports still go to the removed approver instead of the owner.

    Next Steps: Reply with @MelvinBot <your feedback> if Applause confirms either case.


    view run

  13. ikevin127 commented on Oct 1, 2026

    @ikevin127
    Contributor

    Based on the above comment:

    Both of your results match how the code is designed to work.

    Without the beta, removing the workflow is intended. When the removed approver is the only approver of a non-default workflow, and the owner already approves the default workflow, the code removes that workflow. Its members go back to the default workflow, where the owner approves their reports. The code replaces the approver with the owner only when the default workflow's approver is someone other than the owner. On a new workspace the owner is the default approver, so the workflow goes away. That is what you saw, and what the Applause tester most likely read as "not replaced."

    With all betas on, you saw the expected result. That means the rules-based gap I described doesn't reproduce.

    my previous reproduction attempts:

    • with all betas enabled: the actual issue's expected result happens - workspace owner becomes approver when the approver of the added workflow approval is removed as member from WS
    • without all betas enabled (just default new private domain account fresh sign-up): the actual result differs for me - when the approver of the added workflow approval is removed as member from WS, that added workflow approval is removed / goes away leaving me with only the original approval workflow that was already there on a new account
    All Betas No Betas
    all-betas.mov
    no-betas.mov

    and the issue's OP description mentioning nothing about betas in precondition and Actual Result + video confirms the approval workflow remains instead of being deleted, despite the approver being removed as member from WS:

    Approver is not replaced by the workspace owner in the workflow after being removed.

    I'd say we have two options in this situation:

    • close it as intended behaviour
    • ask QA to add more details in the issue OP regarding enabled / non-enabled betas, account type (fresh sign-up, public / private domain email - AFAIK expensifail is private domain)

    🎀👀🎀 C+ reviewed

  14. melvin-bot commented on Oct 1, 2026

    @melvin-bot

    Triggered auto assignment to @chuckdries, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

  15. melvin-bot commented on Oct 6, 2026

    @melvin-bot

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

  16. chuckdries commented on Oct 6, 2026

    @chuckdries
    Contributor

    Sorry for the delay on this. So, you weren't able to repro the observed behavior with betas on or off? I'll ping QA.

  17. ikevin127 commented on Oct 6, 2026

    @ikevin127
    Contributor

    Correct, I detailed my findings in this comment. Thanks for pushing this to QA Chuck 🙌

  18. m-natarajan commented on Oct 7, 2026

    @m-natarajan

    Not repro on Windows 10/Chrome/Build v9.5.4-0

    2026-10-07.06-04-51.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions