You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$175] Workflow - Removing approver from workspace does not replace them with the WS owner #102687
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.
The code notes that the backend rejects employeeList routing changes once approvals are rule-based, so the legacy calls can't fix this anyway: Workflow.ts:546-549
The legacy helper that swaps in the owner works and has tests. It just never receives rule-based workflows: WorkflowUtils.ts:598-629
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:
Build the workflows from the policy's rules with convertApprovalWorkflowRulesToWorkflows, the same way the Workflows tab does.
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.
Run the existing updateWorkflowDataOnApproverRemoval. Save each changed workflow with updateApprovalWorkflowRules, or with removeApprovalWorkflowRules when the workflow should be removed. Skip unchanged workflows.
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.
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.
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.
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
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:
isPolicyApprover ignores rule-based workflows:
In src/libs/PolicyUtils.ts (lines 821–828):
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.
Member removal early-returns and bypasses workflow updates:
In WorkspaceMemberDetailsPage.tsx (lines 243–247):
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.
Approval workflows are converted from legacy employeeList instead of rules:
In both pages:
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?
In src/libs/PolicyUtils.ts:
Update isPolicyApprover to also inspect rule-based approval workflows when rules are present:
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).
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.
@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.
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:
The default workflow's approver was not the owner, and the custom workflow still disappeared or kept the removed approver.
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.
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.
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)
Activity
applause-bot commentedon Sep 30, 2026
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
MelvinBot commentedon Sep 30, 2026
Proposal
What is the root cause of that problem?
With the
multipleApproversbeta 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 inemployeeList(submitsTo/forwardsTo), and they only sendemployeeList-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
WorkspaceWorkflowsApprovalsCreatePage.tsx:78-82WorkflowsApprovalsTab.tsx:145-157submitsTo, and there is no check that the approver is still a member:WorkflowUtils.ts:1325-1331removeUsersonly usesemployeeListand legacy workflow actions:WorkspaceMembersPage.tsx:235-271removeUserhas the same logic:WorkspaceMemberDetailsPage.tsx:239-268isPolicyApproveronly checkspolicy.approverandemployeeList:PolicyUtils.ts:821-828employeeListrouting changes once approvals are rule-based, so the legacy calls can't fix this anyway:Workflow.ts:546-549removeMemberssends onlyemailListandpolicyID:Member.ts:592-597WorkflowUtils.ts:598-629What changes do you think we should make in order to solve the problem?
When the
multipleApproversbeta is on, updateremoveUsersinWorkspaceMembersPageandremoveUserinWorkspaceMemberDetailsPageto work with rules:convertApprovalWorkflowRulesToWorkflows, the same way the Workflows tab does.isPolicyApproveris 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.updateWorkflowDataOnApproverRemoval. Save each changed workflow withupdateApprovalWorkflowRules, or withremoveApprovalWorkflowRuleswhen the workflow should be removed. Skip unchanged workflows.Open questions
multipleApproversbeta. 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.DeleteMembersFromWorkspaceshould 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
melvin-bot commentedon Sep 30, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ikevin127 (
External)[-]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[/+]melvin-bot commentedon Sep 30, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022105381088130591968
bonnhatnguyen commentedon Sep 30, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
In a workspace with the
multipleApproversbeta 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.tsxandWorkspaceMemberDetailsPage.tsxrelies exclusively on legacyemployeeListhelpers rather than rule-based workflows:isPolicyApproverignores rule-based workflows:In
src/libs/PolicyUtils.ts(lines 821–828):isPolicyApproveronly checkspolicy.approverandpolicy.employeeList. In rule-based approval workflows, routing is stored in approval rules underONYXKEYS.COLLECTION.RULE(policy.rules), whererule.approverholds the approver's email. Consequently,isPolicyApproverreturnsfalsefor approvers configured through rules.Member removal early-returns and bypasses workflow updates:
In
WorkspaceMemberDetailsPage.tsx(lines 243–247):Because
isPolicyApproverreturnsfalse,removeUserimmediately proceeds toremoveMemberAndCloseModal()without reassigning the workflow to the workspace owner. Similarly, inWorkspaceMembersPage.tsx(lines 237–239),hasApproversevaluates tofalse, skippingupdateWorkflowDataOnApproverRemoval.Approval workflows are converted from legacy
employeeListinstead of rules:In both pages:
Even if the check passed,
approvalWorkflowsis generated fromconvertPolicyEmployeesToApprovalWorkflowsrather than checkingisMultipleApproversBetaEnabledand usingconvertApprovalWorkflowRulesToWorkflows(as done inWorkflowsApprovalsTab.tsx).What changes do you think we should make in order to solve the problem?
In
src/libs/PolicyUtils.ts:Update
isPolicyApproverto also inspect rule-based approval workflows when rules are present:In
src/pages/workspace/WorkspaceMembersPage.tsxandsrc/pages/workspace/members/WorkspaceMemberDetailsPage.tsx:ONYXKEYS.COLLECTION.RULE.isMultipleApproversBetaEnabledistrue, deriveapprovalWorkflowsusingconvertApprovalWorkflowRulesToWorkflows({rules, policy, personalDetails, localeCompare}), matchingWorkflowsApprovalsTab.tsx.removeUsers/removeUser, passrulestoisPolicyApprover.isMultipleApproversBetaEnabled, executeupdateApprovalWorkfloworsetApprovalWorkflowRulesusing the updated workflow diff so that rules pointing to the removed approver are updated to the workspace owner (ownerDetails.login).Add Unit Tests:
tests/unit/PolicyUtilsTest.tsverifying thatisPolicyApproverreturnstruewhen a user is an approver in rule-based workflow rules.tests/actions/PolicyTest.tsverifying 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 assetApprovalWorkflowRulesandupdateApprovalWorkflow). 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.camesenin commentedon Sep 30, 2026
melvin-bot commentedon Sep 30, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
ikevin127 commentedon Oct 1, 2026
@MelvinBot I tried reproducing, here's what happened on my side - 2 scenarios:
What do you suggest in this case ? Given your proposal on this issue which doesn't seem accurate given my reproduction.
MelvinBot commentedon Oct 1, 2026
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
WorkflowUtils.ts:598-629. IfdefaultHasOwneris true, it returnsremoveApprovalWorkflow: true. Otherwise it puts the owner in place of the removed approver.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:
Next Steps: Reply with
@MelvinBot <your feedback>if Applause confirms either case.view run
ikevin127 commentedon Oct 1, 2026
Based on the above comment:
my previous reproduction attempts:
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:
I'd say we have two options in this situation:
🎀👀🎀 C+ reviewed
melvin-bot commentedon Oct 1, 2026
Triggered auto assignment to @chuckdries, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
melvin-bot commentedon Oct 6, 2026
@chuckdries Huh... This is 4 days overdue. Who can take care of this?
chuckdries commentedon Oct 6, 2026
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.
ikevin127 commentedon Oct 6, 2026
Correct, I detailed my findings in this comment. Thanks for pushing this to QA Chuck 🙌
m-natarajan commentedon Oct 7, 2026
Not repro on Windows 10/Chrome/Build v9.5.4-0
2026-10-07.06-04-51.mp4