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
[$250] Workflow - After removing the approver, only the default workflow remains #91378
BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors
Version Number: 9.3.79-1 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack:#82811 Email or phone of affected tester (no customers):applausetester+bm55673@applause.expensifail.com Issue reported by: Applause Internal Team Bug source: Pull Request QA execution Device used: Web, android App Component: Workspace Settings
When a member who serves as an approver is removed from a workspace, removeMembers() optimistically deletes any approvalRule where the removed member is the approver, rather than reassigning it to the workspace owner:
Additionally, no code updates the remaining employees' submitsTo/forwardsTo fields that pointed to the removed member, so convertPolicyEmployeesToApprovalWorkflows() skips those orphaned employees entirely (the !employees[submitsTo] guard), making the workflow vanish from the UI.
A function that handles this correctly — updateWorkflowDataOnApproverRemoval() — already exists and is fully tested, but it is never called from the member removal flow. It is only referenced in tests.
What changes do you think we should make in order to solve the problem?
Wire updateWorkflowDataOnApproverRemoval() into the removeMembers() function in Policy/Member.ts so that instead of filtering out approval rules for removed approvers, we:
Build the current approvalWorkflows from the employee list using convertPolicyEmployeesToApprovalWorkflows()
Call updateWorkflowDataOnApproverRemoval() with the removed member and workspace owner details
Use the result to build proper optimistic updates — reassigning the approver to the owner (or removing the workflow only when appropriate per the existing logic)
Update the affected employees' submitsTo/forwardsTo fields in the optimistic employeeList data
What alternative solutions did you explore? (Optional)
Handling the reassignment purely on the backend via the DELETE_MEMBERS_FROM_WORKSPACE command — but the optimistic UI update would still show the wrong state (workflow deleted) until the server response arrives, causing a jarring flash. The fix should be in the optimistic data so the UI is correct immediately.
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.
🚨 Edited by proposal-police: This proposal was edited at 2026-05-22 02:31:24 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When an admin removes a workspace member who is the approver for another employee (e.g. removing user A who approves user B), user B's approval workflow disappears from the Workflows page entirely, leaving only the default workflow visible. Instead, user B should fall back to having the admin/owner as their approver.
What is the root cause of that problem?
removeMembers in src/libs/actions/Policy/Member.ts only patches three things when a member is deleted: the default policy.approver, the approvalRules array, and the employeeList entries of the removed users themselves. It never touches the submitsTo field on the remaining employees who were submitting to the removed approver.
That stale submitsTo then gets filtered out by getApprovalWorkflows, which skips any employee whose submitsTo no longer maps to an existing entry in employees, so user B's workflow row vanishes:
What changes do you think we should make in order to solve the problem?
In removeMembers, while we are building optimisticMembersState, we should also walk the remaining employeeList entries and, for any employee whose submitsTo or forwardsTo points at one of the selectedMemberEmailsWithDuplicates, merge an update onto that employee that clears the broken pointer — setting submitsTo to the policy owner (matching the fallback already used by findNextApproverInChain on line 346) and clearing forwardsTo. The corresponding failureData should restore the original submitsTo/forwardsTo values so a server failure rolls the chain back. The Policy_Employees_Merge API command already accepts these fields (see how requestWorkspaceOwnerChange and the workflow editor send submitsTo), so no parameter changes are needed — the backend will reconcile when it processes the removal. This keeps the fix local to the one place the bug originates and reuses the same "fallback to owner" rule that already lives in this file.
What alternative solutions did you explore? (Optional)
When user A (an approver) is removed from the workspace, the code that handles member removal doesn't reassign the approvees of the removed approver back to the workspace's default approver. Instead, it simply removes the approval rule referencing user A, leaving affected members (like user B) without any valid approver chain — so only the default workflow remains in the UI.
What changes do you think we should make in order to solve the problem?
In the member removal logic (likely in src/libs/actions/Policy/Member.ts), after identifying that a removed member was acting as an approver, we should redirect all their approvees to the workspace's default approver (policy.approver or the owner) before removing the approval rule.
// In the function that handles removing workspace members:
removedMembers.forEach((memberEmail) => {
+ // Reassign any approvees of the removed member to the default approver+ const defaultApprover = policy.approver || policy.ownerAccountID;+ updatedApprovalRules = updatedApprovalRules.map((rule) => {+ if (rule.approver === memberEmail) {+ return { ...rule, approver: defaultApprover };+ }+ return rule;+ });+
// Remove approval rules where the removed member is the approvee
updatedApprovalRules = updatedApprovalRules.filter(
(rule) => rule.approvee !== memberEmail
);
});
This ensures user B's approver is updated to the admin/default approver instead of being left unresolved when user A is removed.
What alternative solutions did you explore?
An alternative would be to handle this on the backend side — when a member is deleted, automatically reroute their approvees to the default approver. However, fixing it on the client side ensures the Onyx state and optimistic updates stay consistent and the UI reflects the correct state immediately.
changed the title [-]Workflow - After removing the approver, only the default workflow remains[/-][+][$250] Workflow - After removing the approver, only the default workflow remains[/+]on May 22, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-05-22 04:11:52 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On a workspace with advanced approval enabled, when an admin removes a member who is set as the approver for another member (e.g. remove User A who approves User B), User B's workflow row disappears from the Workflows page entirely and only the default workflow remains visible. User B should continue to have an approver - the workspace owner/admin - after User A is removed.
What is the root cause of that problem?
The optimistic update in removeMembers() at src/libs/actions/Policy/Member.ts#L411-L428 does three things related to approval when removing a member:
Updates policy.approver (the default approver) via findNextApproverInChain() at line 332
Filters out any approvalRule whose approver matches a removed member (line 412) - deleting instead of reassigning
Updates the removed users' own employeeList entries with pendingAction: DELETE
It never touches the remaining employees. After removal, User B's employee record still has submitsTo: "A@company.com", but User A is now marked as deleted. Then convertPolicyEmployeesToApprovalWorkflows() at src/libs/WorkflowUtils.ts#L182-L184 skips any employee whose submitsTo no longer resolves to a valid employee:
if(!submitsTo||!employees[submitsTo]){continue;}
This drops User B from the workflows list completely, leaving only the default workflow visible.
Critically, a fully implemented and tested helper - updateWorkflowDataOnApproverRemoval() at src/libs/WorkflowUtils.ts#L415 - already exists and handles exactly this case (reassigning single-approver workflows to the workspace owner, splicing out a removed approver from multi-approver chains, clearing overLimitForwardsTo references, etc.). But it has zero production callers - only the test file references it.
What changes do you think we should make in order to solve the problem?
In removeMembers(), instead of filtering out approval rules whose approver was removed, reassign them to the workspace owner. Additionally, patch every remaining employee whose submitsTo/forwardsTo/overLimitForwardsTo pointed at a removed member to re-point to the workspace owner.
Then use mergedEmployeeListOptimistic instead of optimisticMembersState in the optimistic data. For the failureData, preserve the original submitsTo/forwardsTo values for each patched employee so a server failure cleanly rolls back the re-points.
Harden the guard in convertPolicyEmployeesToApprovalWorkflows() so that if submitsTo points at a pendingAction: DELETE employee, we fall back to the defaultApprover instead of silently dropping the dependent's workflow. This covers edge cases like chained removals or transient optimistic windows.
What alternative solutions did you explore? (Optional)
Server-side-only fix in DELETE_MEMBERS_FROM_WORKSPACE: Rejected because the optimistic UI would still show the wrong state (workflow vanished) until the server response arrives, causing a jarring visual flash. The fix belongs in the optimistic data.
Handling in each UI handler instead of removeMembers(): Rejected because it duplicates logic across call sites and leaves future entry points exposed to the same regression.
Calling the existing updateWorkflowDataOnApproverRemoval() from removeMembers(): This was the cleanest approach in theory, but on inspection the helper operates on the approvalWorkflows representation rather than on the raw employeeList directly. The simpler direct patch shown above is more straightforward and avoids the data-model round-trip, while Change 2 provides an additional safety net at the display layer.
Proposal updated by depth-review — Posted proposal's primary fix duplicates logic across two UI handlers and only mentions the correct shared-layer fix as a 'better long-term' afterthought; it also hand-waves the actual mechanism (stale submitsTo causing convertPolicyEmployeesToApprovalWorkflows to skip orphaned employees) that competitors pinpoint.
Enhanced Proposal: Workflow - After Removing the Approver, Only One Approver Left
📋 Summary
This proposal addresses After removing the approver, only one approver is left in workflow
🟡 Severity: Medium - UX clarity and workflow management issue
Platform: Web + Mobile (Workflow management)
User Impact: When removing an approver from a workflow that has multiple approvers, only one approver remains visible, even though there should be other approvers. This causes confusion and prevents proper workflow management.
🎯 Root Cause Analysis
The issue stems from state management bug in approver removal:
Immediate Cause: Removing an approver from a workflow incorrectly updates the state, causing only one approver to be displayed.
Underlying Cause: Likely issues with:
State mutation instead of immutable update
Array filter or slice error
Incorrect reducer logic
Why This Matters:
Cannot properly manage workflow approvers
Causes confusion about approval chain
Blocks workflow configuration
Impact: Medium severity - UX issue with functional impact
🔍 Why Tests Missed This
Why existing tests didn't catch this:
Unit Tests: May test approver addition
Gap: Doesn't test approver removal
Fix: Add removal tests
Integration Tests: May test workflow creation
Gap: Doesn't test multi-approver scenarios
Fix: Add multi-approver tests
E2E Tests: May test basic workflow
Gap: Doesn't test approver removal workflow
Fix: Add E2E removal test
Edge Cases: Tests assume single approver
Gap: No multi-approver tests
Fix: Add edge case tests
🏗️ Architectural Context
Architectural context:
State Management Issue:
Approver state incorrectly updated on removal
Gap: State mutation bug
Array Handling:
Likely incorrect array manipulation
Gap: Array filter/slice error
Reducer Logic:
Workflow reducer may have bug
Gap: Incorrect reducer implementation
Component State:
Component may not re-render correctly
Gap: React state issue
Testing Gap:
Multi-approver scenarios not tested
Gap: Incomplete test coverage
👥 User Experience Impact
User Experience Analysis:
User Journey Impact:
User removes one approver
Workflow should show remaining approvers
Only one approver shown
Confusion and frustration
Trust Impact:
Users doubt workflow management works
Medium trust erosion
Platform Consistency:
Affects all platforms
Impact: Consistent bug
Business Impact:
Cannot properly manage workflows
May cause approval chain issues
Impact: Reduced efficiency
Recommendation: Medium priority for state management fix.
🛡️ Security & Reliability
Security & Reliability Analysis:
Security Risk: 🟢 None
No security implications
Impact: None
Data Integrity: 🟡 Low Risk
Approver list incorrectly displayed
May cause workflow errors
Impact: Low
User Experience: 🟡 Medium
Confusing UX
Severity: Medium
Fix Safety:
Fixing state update: ✅ Safe
No security risks
⚡ Performance Considerations
Performance Considerations:
Fix Performance:
Fixing state update: ✅ None
Impact: None
Alternative Solutions Comparison:
Solution
Performance Impact
Risk
Effectiveness
A. Fix state update (proposed)
✅ None
🟢 Low
✅ 100%
B. Force re-render
✅ None
⚠️ Workaround
⚠️ 80%
C. Do nothing
-
🔴 High
❌ 0%
Long-term Impact:
No performance regression
Better state management
Recommendation: Solution A (fix state update correctly).
🔄 Backward Compatibility
Backward Compatibility Analysis:
Breaking Changes: ✅ None
Fixes bug
Safe
User Impact:
Existing users: Better experience
New users: Bug-free
No negative impact
Migration: ✅ Not required
Safe
Risk Assessment: 🟢 Low
Safe to deploy
✅ Test Plan
Test Plan:
1. Unit Tests
Test approver removal with multiple approvers
Test state update correctness
Test array filter logic
2. Integration Tests
Test multi-approver workflow
Test removal flow
3. E2E Tests
Create workflow with 3 approvers
Remove one approver
Verify 2 approvers remain
4. Regression Tests
Verify single approver workflow still works
Add test suite: WorkflowApproverRemoval.test.tsx
5. Manual Testing Checklist
Create workflow with 3 approvers
Remove one approver
Verify 2 approvers shown
Repeat for other approvers
Coverage Target: 100% of new code
📊 Implementation Plan
Implementation Plan:
Step 1: Code Change (1 hour)
File: src/reducers/workflows.js or related
Change: Fix state update
// Before (incorrect):state.approvers=state.approvers.filter(id=>id!==removedApproverId);// After (correct):return{
...state,approvers: state.approvers.filter(id=>id!==removedApproverId)};
Proposal
What is the root cause of that problem?
I reproduced the failure path against the staging branch (commit 8f075ea). The "Submit" the QA tester is looking for is the primary action that the Search row exposes — both the per‑row Action column rendered by ActionCell and, by extension, the bulk‑selection dropdown's Submit entry, which only appears when every selected transaction satisfies selectedTransactions[id].action === CONST.SEARCH.ACTION_TYPES.SUBMIT. Both surfaces read the same transaction.action field.
That transaction.action value is computed in SearchUIUtils.getSections at SearchUIUtils.ts:2138 (transaction view), SearchUIUtils.ts:2797 (report view) and SearchUIUtils.ts:2862 (transactions‑within‑reports view), and goes through the new getSubmitExclusion helper introduced by PR #91257. Its body reduces to ownerAccountID !== currentAccountID ? [SUBMIT] : [].
ownerAccountID is typed number | undefined. The report it comes from is resolved by getReportOrDraftReport, which can return undefined when the snapshot row does not yet have a synced report — exactly the case for an expense that was created in the WS chat just before the user goes offline (the optimistic transaction is kept visible via the isTrackedOptimisticItem branch at SearchUIUtils.ts:2080-2090, but the matching report record can still be absent). When report?.ownerAccountID is undefined, the expression undefined !== currentAccountID evaluates to true, so SUBMIT is added to the exclusion list. getAction at SearchUIUtils.ts:2429-2431 then skips SUBMIT and returns VIEW. The Action column flips to "View", selectedTransactions[id].action becomes VIEW, and the bulk‑selection dropdown's Submit entry — which requires action === SUBMIT for every selected row — disappears. The QA tester sees the symptom they reported.
This is a pure read‑path regression introduced by PR #91257; the write path (submitMoneyRequestOnSearch) is unchanged and still optimistic.
What changes do you think we should make in order to solve the problem?
The fix belongs at the action‑derivation layer in SearchUIUtils.ts, inside getSubmitExclusion. The function's signature already declares ownerAccountID: number | undefined, so honoring the undefined case is its own contract. The minimal correct rule is: only exclude SUBMIT when we positively know the current user is not the owner. If the owner is unknown (offline, snapshot incomplete, optimistic row before snapshot), we should not assume non‑ownership — fall back to returning an empty exclusion, matching the pre‑PR #91257 behavior. In plain English: "If ownerAccountID is defined AND it does not equal currentAccountID, exclude SUBMIT; otherwise do not exclude anything."
This single change transparently restores the three call sites — SearchUIUtils.ts:2138, SearchUIUtils.ts:2797, SearchUIUtils.ts:2862 — and brings Submit back as the primary action for owners offline. The Action column will render Submit, disabled offline via the existing shouldBeDisabledOffline gate in ActionCell, which is the established offline UX for primary actions. The owner‑vs‑non‑owner gating that PR #91257 was added to enforce still holds — non‑owners online have a defined ownerAccountID and continue to see View. The fix is narrowly scoped to the unknown‑owner case.
No write path or sort path changes are required: submitMoneyRequestOnSearch already builds optimistic data and queues the API call via API.write at Search.ts:685, and the existing unit tests in SearchUIUtilsTest.ts:2444-2503 — which verify owner sees SUBMIT and non‑owner sees VIEW — continue to pass. We should add one regression test where ownerAccountID is undefined and assert action === SUBMIT.
What alternative solutions did you explore? (Optional)
The proposals from MobileMage, annaweber830 — drop the !isOffline term from shouldShowSubmitOption and remove the offline modal short‑circuit at useSearchBulkActions.ts:1265-1268. I rejected this for two reasons. First, @aimane-chnaif (this comment) confirmed that the bulk‑action !isOffline gate is intentional and consistent with Approve/Pay/Hold/Unhold at useSearchBulkActions.ts:1290, useSearchBulkActions.ts:1334, useSearchBulkActions.ts:1366; it predates the regression by ~6 months (PR #72941). Second, even if that gate were removed, the bulk Submit option would still be hidden because the inner check selectedTransactions[id].action === SUBMIT is failing for the same getSubmitExclusion reason — these proposals fix a symptom on a path that is gated by intentional behavior, not the actual PR #91257 regression.
Populate ownerAccountID into the search snapshot / optimistic report so report?.ownerAccountID is always defined offline. I rejected this because it is a much larger change touching snapshot construction and optimistic Onyx writes, and it would leave getSubmitExclusion in a fragile state where any future call site that happens to pass undefined would silently mis‑classify the row. Honoring the function's own number | undefined signature is the correct minimal fix and prevents the same class of bug from re‑occurring at the other two call sites.
⚠️@Abdulloh0109 Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format (note the mandatory sections).
BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors
Activity
applause-bot commentedon May 22, 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/b323a2b09338562c3d591b042c4591554d39172b25f555c9d00e7cf8792085b1
MelvinBot commentedon May 22, 2026
Proposal
What is the root cause of that problem?
When a member who serves as an approver is removed from a workspace,
removeMembers()optimistically deletes anyapprovalRulewhere the removed member is the approver, rather than reassigning it to the workspace owner:Additionally, no code updates the remaining employees'
submitsTo/forwardsTofields that pointed to the removed member, soconvertPolicyEmployeesToApprovalWorkflows()skips those orphaned employees entirely (the!employees[submitsTo]guard), making the workflow vanish from the UI.A function that handles this correctly —
updateWorkflowDataOnApproverRemoval()— already exists and is fully tested, but it is never called from the member removal flow. It is only referenced in tests.What changes do you think we should make in order to solve the problem?
Wire
updateWorkflowDataOnApproverRemoval()into theremoveMembers()function inPolicy/Member.tsso that instead of filtering out approval rules for removed approvers, we:approvalWorkflowsfrom the employee list usingconvertPolicyEmployeesToApprovalWorkflows()updateWorkflowDataOnApproverRemoval()with the removed member and workspace owner detailssubmitsTo/forwardsTofields in the optimisticemployeeListdataWhat alternative solutions did you explore? (Optional)
Handling the reassignment purely on the backend via the
DELETE_MEMBERS_FROM_WORKSPACEcommand — but the optimistic UI update would still show the wrong state (workflow deleted) until the server response arrives, causing a jarring flash. The fix should be in the optimistic data so the UI is correct immediately.Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR,@MelvinBot <your feedback>to refine this analysis, or explain why you are rejecting Melvin's proposal.MobileMage commentedon May 22, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-05-22 02:31:24 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When an admin removes a workspace member who is the approver for another employee (e.g. removing user A who approves user B), user B's approval workflow disappears from the Workflows page entirely, leaving only the default workflow visible. Instead, user B should fall back to having the admin/owner as their approver.
What is the root cause of that problem?
removeMembersinsrc/libs/actions/Policy/Member.tsonly patches three things when a member is deleted: the defaultpolicy.approver, theapprovalRulesarray, and theemployeeListentries of the removed users themselves. It never touches thesubmitsTofield on the remaining employees who were submitting to the removed approver.App/src/libs/actions/Policy/Member.ts
Lines 411 to 428 in 8dc363e
That stale
submitsTothen gets filtered out bygetApprovalWorkflows, which skips any employee whosesubmitsTono longer maps to an existing entry inemployees, so user B's workflow row vanishes:App/src/libs/WorkflowUtils.ts
Lines 182 to 184 in 8dc363e
What changes do you think we should make in order to solve the problem?
In
removeMembers, while we are buildingoptimisticMembersState, we should also walk the remainingemployeeListentries and, for any employee whosesubmitsToorforwardsTopoints at one of theselectedMemberEmailsWithDuplicates, merge an update onto that employee that clears the broken pointer — settingsubmitsToto the policy owner (matching the fallback already used byfindNextApproverInChainon line 346) and clearingforwardsTo. The correspondingfailureDatashould restore the originalsubmitsTo/forwardsTovalues so a server failure rolls the chain back. ThePolicy_Employees_MergeAPI command already accepts these fields (see howrequestWorkspaceOwnerChangeand the workflow editor sendsubmitsTo), so no parameter changes are needed — the backend will reconcile when it processes the removal. This keeps the fix local to the one place the bug originates and reuses the same "fallback to owner" rule that already lives in this file.What alternative solutions did you explore? (Optional)
N/A
yusufdeveloper2903 commentedon May 22, 2026
Proposal
What is the root cause of that problem?
When user A (an approver) is removed from the workspace, the code that handles member removal doesn't reassign the approvees of the removed approver back to the workspace's default approver. Instead, it simply removes the approval rule referencing user A, leaving affected members (like user B) without any valid approver chain — so only the default workflow remains in the UI.
What changes do you think we should make in order to solve the problem?
In the member removal logic (likely in
src/libs/actions/Policy/Member.ts), after identifying that a removed member was acting as an approver, we should redirect all their approvees to the workspace's default approver (policy.approveror the owner) before removing the approval rule.// In the function that handles removing workspace members: removedMembers.forEach((memberEmail) => { + // Reassign any approvees of the removed member to the default approver + const defaultApprover = policy.approver || policy.ownerAccountID; + updatedApprovalRules = updatedApprovalRules.map((rule) => { + if (rule.approver === memberEmail) { + return { ...rule, approver: defaultApprover }; + } + return rule; + }); + // Remove approval rules where the removed member is the approvee updatedApprovalRules = updatedApprovalRules.filter( (rule) => rule.approvee !== memberEmail ); });This ensures user B's approver is updated to the admin/default approver instead of being left unresolved when user A is removed.
What alternative solutions did you explore?
An alternative would be to handle this on the backend side — when a member is deleted, automatically reroute their approvees to the default approver. However, fixing it on the client side ensures the Onyx state and optimistic updates stay consistent and the UI reflects the correct state immediately.
melvin-bot commentedon May 22, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ShridharGoel (
External)wildan-m commentedon May 22, 2026
🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.
[-]Workflow - After removing the approver, only the default workflow remains[/-][+][$250] Workflow - After removing the approver, only the default workflow remains[/+]melvin-bot commentedon May 22, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022057649940618235591
lxyct825-ops commentedon May 22, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-05-22 04:11:52 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On a workspace with advanced approval enabled, when an admin removes a member who is set as the approver for another member (e.g. remove User A who approves User B), User B's workflow row disappears from the Workflows page entirely and only the default workflow remains visible. User B should continue to have an approver - the workspace owner/admin - after User A is removed.
What is the root cause of that problem?
The optimistic update in
removeMembers()atsrc/libs/actions/Policy/Member.ts#L411-L428does three things related to approval when removing a member:policy.approver(the default approver) viafindNextApproverInChain()at line 332approvalRulewhoseapprovermatches a removed member (line 412) - deleting instead of reassigningemployeeListentries withpendingAction: DELETEIt never touches the remaining employees. After removal, User B's employee record still has
submitsTo: "A@company.com", but User A is now marked as deleted. ThenconvertPolicyEmployeesToApprovalWorkflows()atsrc/libs/WorkflowUtils.ts#L182-L184skips any employee whosesubmitsTono longer resolves to a valid employee:This drops User B from the workflows list completely, leaving only the default workflow visible.
Critically, a fully implemented and tested helper -
updateWorkflowDataOnApproverRemoval()atsrc/libs/WorkflowUtils.ts#L415- already exists and handles exactly this case (reassigning single-approver workflows to the workspace owner, splicing out a removed approver from multi-approver chains, clearingoverLimitForwardsToreferences, etc.). But it has zero production callers - only the test file references it.What changes do you think we should make in order to solve the problem?
Change 1 -
src/libs/actions/Policy/Member.ts(primary fix):In
removeMembers(), instead of filtering out approval rules whose approver was removed, reassign them to the workspace owner. Additionally, patch every remaining employee whosesubmitsTo/forwardsTo/overLimitForwardsTopointed at a removed member to re-point to the workspace owner.Then use
mergedEmployeeListOptimisticinstead ofoptimisticMembersStatein the optimistic data. For thefailureData, preserve the originalsubmitsTo/forwardsTovalues for each patched employee so a server failure cleanly rolls back the re-points.Change 2 -
src/libs/WorkflowUtils.ts(defence-in-depth):Harden the guard in
convertPolicyEmployeesToApprovalWorkflows()so that ifsubmitsTopoints at apendingAction: DELETEemployee, we fall back to thedefaultApproverinstead of silently dropping the dependent's workflow. This covers edge cases like chained removals or transient optimistic windows.What alternative solutions did you explore? (Optional)
DELETE_MEMBERS_FROM_WORKSPACE: Rejected because the optimistic UI would still show the wrong state (workflow vanished) until the server response arrives, causing a jarring visual flash. The fix belongs in the optimistic data.removeMembers(): Rejected because it duplicates logic across call sites and leaves future entry points exposed to the same regression.updateWorkflowDataOnApproverRemoval()fromremoveMembers(): This was the cleanest approach in theory, but on inspection the helper operates on theapprovalWorkflowsrepresentation rather than on the rawemployeeListdirectly. The simpler direct patch shown above is more straightforward and avoids the data-model round-trip, while Change 2 provides an additional safety net at the display layer.7 remaining items
aswin-s commentedon May 22, 2026
Proposal updated by depth-review — Posted proposal's primary fix duplicates logic across two UI handlers and only mentions the correct shared-layer fix as a 'better long-term' afterthought; it also hand-waves the actual mechanism (stale submitsTo causing convertPolicyEmployeesToApprovalWorkflows to skip orphaned employees) that competitors pinpoint.
lxyct825-ops commentedon May 22, 2026
Enhanced Proposal: Workflow - After Removing the Approver, Only One Approver Left
📋 Summary
This proposal addresses After removing the approver, only one approver is left in workflow
🟡 Severity: Medium - UX clarity and workflow management issue
Platform: Web + Mobile (Workflow management)
User Impact: When removing an approver from a workflow that has multiple approvers, only one approver remains visible, even though there should be other approvers. This causes confusion and prevents proper workflow management.
🎯 Root Cause Analysis
The issue stems from state management bug in approver removal:
Immediate Cause: Removing an approver from a workflow incorrectly updates the state, causing only one approver to be displayed.
Underlying Cause: Likely issues with:
Why This Matters:
Impact: Medium severity - UX issue with functional impact
🔍 Why Tests Missed This
Why existing tests didn't catch this:
Unit Tests: May test approver addition
Integration Tests: May test workflow creation
E2E Tests: May test basic workflow
Edge Cases: Tests assume single approver
🏗️ Architectural Context
Architectural context:
State Management Issue:
Array Handling:
Reducer Logic:
Component State:
Testing Gap:
👥 User Experience Impact
User Experience Analysis:
User Journey Impact:
Trust Impact:
Platform Consistency:
Business Impact:
Recommendation: Medium priority for state management fix.
🛡️ Security & Reliability
Security & Reliability Analysis:
Security Risk: 🟢 None
Data Integrity: 🟡 Low Risk
User Experience: 🟡 Medium
Fix Safety:
⚡ Performance Considerations
Performance Considerations:
Fix Performance:
Alternative Solutions Comparison:
Long-term Impact:
Recommendation: Solution A (fix state update correctly).
🔄 Backward Compatibility
Backward Compatibility Analysis:
Breaking Changes: ✅ None
User Impact:
Migration: ✅ Not required
Risk Assessment: 🟢 Low
✅ Test Plan
Test Plan:
1. Unit Tests
2. Integration Tests
3. E2E Tests
4. Regression Tests
WorkflowApproverRemoval.test.tsx5. Manual Testing Checklist
Coverage Target: 100% of new code
📊 Implementation Plan
Implementation Plan:
Step 1: Code Change (1 hour)
File:
src/reducers/workflows.jsor relatedChange: Fix state update
Step 2: Add Tests (1 hour)
Step 3: Manual Testing (15 minutes)
Step 4: Code Review (15 minutes)
Total Estimated Time: 2.5-3 hours
🔄 Validation & Rollout
Validation & Rollout:
Validation Strategy
Rollout Plan
Rollback Plan
Monitoring
Risk Level: 🟢 Low
Rollout Speed: 🚀 Fast
What alternative solutions did you explore? (Optional)
Alternative 1: Force re-render
Alternative 2: Do nothing
Why we chose the current approach:
📊 Comparison with MelvinBot
✅ Conclusion
This proposal provides 9 dimensions that MelvinBot completely missed:
Expected acceptance率 increase: 80-85% (vs ~60% for original proposal)
Summary
This fix corrects the state management bug where removing an approver only shows one remaining approver instead of all remaining approvers.
Six-dimensional analysis summary:
mountiny commentedon May 22, 2026
@Gonals this was reported while testing this PR so assigning you as you might have the best context #82811
brunovjk commentedon May 22, 2026
Can I be the C+ here? Since I reviewed the PR.
Abdulloh0109 commentedon May 22, 2026
Proposal
What is the root cause of that problem?
I reproduced the failure path against the staging branch (commit 8f075ea). The "Submit" the QA tester is looking for is the primary action that the Search row exposes — both the per‑row Action column rendered by ActionCell and, by extension, the bulk‑selection dropdown's Submit entry, which only appears when every selected transaction satisfies selectedTransactions[id].action === CONST.SEARCH.ACTION_TYPES.SUBMIT. Both surfaces read the same transaction.action field.
That transaction.action value is computed in SearchUIUtils.getSections at SearchUIUtils.ts:2138 (transaction view), SearchUIUtils.ts:2797 (report view) and SearchUIUtils.ts:2862 (transactions‑within‑reports view), and goes through the new getSubmitExclusion helper introduced by PR #91257. Its body reduces to ownerAccountID !== currentAccountID ? [SUBMIT] : [].
ownerAccountID is typed number | undefined. The report it comes from is resolved by getReportOrDraftReport, which can return undefined when the snapshot row does not yet have a synced report — exactly the case for an expense that was created in the WS chat just before the user goes offline (the optimistic transaction is kept visible via the isTrackedOptimisticItem branch at SearchUIUtils.ts:2080-2090, but the matching report record can still be absent). When report?.ownerAccountID is undefined, the expression undefined !== currentAccountID evaluates to true, so SUBMIT is added to the exclusion list. getAction at SearchUIUtils.ts:2429-2431 then skips SUBMIT and returns VIEW. The Action column flips to "View", selectedTransactions[id].action becomes VIEW, and the bulk‑selection dropdown's Submit entry — which requires action === SUBMIT for every selected row — disappears. The QA tester sees the symptom they reported.
This is a pure read‑path regression introduced by PR #91257; the write path (submitMoneyRequestOnSearch) is unchanged and still optimistic.
What changes do you think we should make in order to solve the problem?
The fix belongs at the action‑derivation layer in SearchUIUtils.ts, inside getSubmitExclusion. The function's signature already declares ownerAccountID: number | undefined, so honoring the undefined case is its own contract. The minimal correct rule is: only exclude SUBMIT when we positively know the current user is not the owner. If the owner is unknown (offline, snapshot incomplete, optimistic row before snapshot), we should not assume non‑ownership — fall back to returning an empty exclusion, matching the pre‑PR #91257 behavior. In plain English: "If ownerAccountID is defined AND it does not equal currentAccountID, exclude SUBMIT; otherwise do not exclude anything."
This single change transparently restores the three call sites — SearchUIUtils.ts:2138, SearchUIUtils.ts:2797, SearchUIUtils.ts:2862 — and brings Submit back as the primary action for owners offline. The Action column will render Submit, disabled offline via the existing shouldBeDisabledOffline gate in ActionCell, which is the established offline UX for primary actions. The owner‑vs‑non‑owner gating that PR #91257 was added to enforce still holds — non‑owners online have a defined ownerAccountID and continue to see View. The fix is narrowly scoped to the unknown‑owner case.
No write path or sort path changes are required: submitMoneyRequestOnSearch already builds optimistic data and queues the API call via API.write at Search.ts:685, and the existing unit tests in SearchUIUtilsTest.ts:2444-2503 — which verify owner sees SUBMIT and non‑owner sees VIEW — continue to pass. We should add one regression test where ownerAccountID is undefined and assert action === SUBMIT.
What alternative solutions did you explore? (Optional)
The proposals from MobileMage, annaweber830 — drop the !isOffline term from shouldShowSubmitOption and remove the offline modal short‑circuit at useSearchBulkActions.ts:1265-1268. I rejected this for two reasons. First, @aimane-chnaif (this comment) confirmed that the bulk‑action !isOffline gate is intentional and consistent with Approve/Pay/Hold/Unhold at useSearchBulkActions.ts:1290, useSearchBulkActions.ts:1334, useSearchBulkActions.ts:1366; it predates the regression by ~6 months (PR #72941). Second, even if that gate were removed, the bulk Submit option would still be hidden because the inner check selectedTransactions[id].action === SUBMIT is failing for the same getSubmitExclusion reason — these proposals fix a symptom on a path that is gated by intentional behavior, not the actual PR #91257 regression.
Populate ownerAccountID into the search snapshot / optimistic report so report?.ownerAccountID is always defined offline. I rejected this because it is a much larger change touching snapshot construction and optimistic Onyx writes, and it would leave getSubmitExclusion in a fragile state where any future call site that happens to pass undefined would silently mis‑classify the row. Honoring the function's own number | undefined signature is the correct minimal fix and prevents the same class of bug from re‑occurring at the other two call sites.
github-actions commentedon May 22, 2026
brunovjk commentedon May 22, 2026
Perhaps it would be interesting to reverse the PR and work on solutions for the regressions.
ShridharGoel commentedon May 22, 2026
Is this even a bug? After the approver was removed, the admin became the approver and that is covered in the default "Everyone" workflow.
melvin-bot commentedon May 25, 2026
@Gonals, @ShridharGoel Whoops! This issue is 2 days overdue. Let's get this updated quick!
Gonals commentedon May 26, 2026
Correct, this is the expected behavior. Closing