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
Agents-Additional greyed‑out workflow appears after changing deleted agent in offline #93260
Version Number: v9.4.5-0 Reproducible in staging?: Yes Reproducible in production?: No If this was caught during regression testing, add the test name, ID and link from BrowserStack:#92286 Email or phone of affected tester (no customers):applausetester+ag090626@applause.expensifail.com Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Windows 11/ Chrome, Samsung S23FE/ Android 16, iPhone 13 Mini/ iOS 26.3 App Component: Workspace Settings
Action Performed:
Launch the Expensify app
Go to "Account" > "Agents"
Create a new agent.
Go to "Workspaces" > "Members"
Add the Agent to the workpace
Go to "Workspaces" > "Workflows"
Tap on "Add Agent" > "Save"
Go offline
Return to "Account" > Agents" and delete the agent
Return to "Workspaces" > "Workflows"
Tap on approver to open "Edit Approval" RHP
Click on "Approver" field > "Approver" field
Select a member
Tap Save > Save
Expected Result:
No extra workflow appears.
Actual Result:
A greyed‑out workflow appears with the deleted agent.
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
Identify the pull request that introduced this issue and revert it.
Please re-state the problem that we are trying to solve in this issue.
After deleting an agent offline and then editing an approval workflow where that agent was the approver, a phantom greyed‑out workflow showing the deleted agent appears. This is a regression from #92286 (in this StagingDeployCash).
What is the root cause of that problem?
PR #92286 made deleteAgent optimistically mark the agent's row in every policy employeeList with pendingAction: DELETE, so the workflow UI strikes it through while the delete is in flight (Agent.ts:354-377). The whole strikethrough/hide behavior depends on that DELETE marker surviving — convertPolicyEmployeesToApprovalWorkflows only excludes a member and suppresses its pending styling when pendingAction === DELETE (WorkflowUtils.ts:184-185, 233, 243-250).
Saving an edited approval clobbers that DELETE marker to UPDATE, so the deleted agent is no longer hidden and instead renders as a greyed‑out (pending) workflow. Two spots in the save path do this:
The membersToRemove (WorkflowUtils.ts:416-424) and approversToRemove (WorkflowUtils.ts:428-436) branches set pendingAction unconditionally to UPDATE — unlike the main approver loop, they have no DELETE‑preserving check at all.
When the user swaps the approver away from the deleted agent, the agent goes into approversToRemove, so updatedEmployees[agent] = {forwardsTo: '', pendingAction: UPDATE}. That row is MERGEd into the policy's employeeList, overwriting the existing DELETE. On recompute the agent now carries UPDATE, which is not filtered/suppressed → greyed‑out phantom workflow.
What changes do you think we should make in order to solve the problem?
Preserve the agent's DELETE pendingAction through the workflow‑edit save so the existing hide/strikethrough logic keeps working:
In Workflow.ts:107, don't blanket‑null pendingAction; keep it when it's DELETE (e.g. pendingAction: value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE ? value.pendingAction : null).
In the membersToRemove and approversToRemove branches of convertApprovalWorkflowToPolicyEmployees, mirror the main loop's guard so a previous DELETE is retained instead of overwritten with UPDATE.
A pending‑delete agent should never be re‑written with an ADD/UPDATE pendingAction. Add a unit test in WorkflowUtilsTest/AgentActionTest covering "edit approver while an approver row is pending‑delete".
What alternative solutions did you explore? (Optional)
Because this is a time‑sensitive deploy blocker, reverting #92286 is the fastest way to unblock the deploy if a forward fix can't land quickly — the offline strikethrough is a nice‑to‑have, and reverting removes the DELETE marker that the save path mishandles.
Confidence & verification
High confidence from static tracing of the data flow (Onyx optimistic MERGE → workflow recompute). Not reproduced in a running app. The mechanism explains all symptoms: offline‑only (optimistic data persists, never reconciled by server), greyed‑out (pendingAction styling), and "deleted agent reappears" (DELETE → UPDATE flip un‑hides the row).
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/93260) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
Same root cause as above — the second workflow is the deleted agent resurfacing, not a real new workflow.
Offline, deleting the agent never actually removes its employeeList row; it only marks it. PR #92286 sets that row to pendingAction: DELETE, and the workflows page relies on DELETE to hide the row (it's filtered out of availableMembers/members and not allowed to spawn or grey a workflow — WorkflowUtils.ts:184, 233, 243, 249).
When you change the approver and save, the agent goes into approversToRemove and its row is re-written with pendingAction: UPDATE (WorkflowUtils.ts:428-436; the DELETE is also already discarded one step earlier at Workflow.ts:107, which nulls every row's pendingAction). That UPDATE row is MERGEd into the policy, overwriting the DELETE marker that was keeping the agent hidden.
So now there are two cards:
The workflow you actually edited — the member now submits to the new approver.
The deleted agent's own still-present row. It's no longer DELETE-suppressed, and it still carries the submitsTo the backend's shareWithEmployees gave it when the agent was promoted to approver (the previous default approver — see the comment at Workflow.ts:117-123). Since each workflow card is keyed on an employee's submitsTo (WorkflowUtils.ts:195), that residual submitsTo makes the resurrected agent render as its own greyed grouping instead of staying hidden.
Both cards are greyed because both rows carry a pending action while you're offline.
The fix in my analysis above resolves this too: preserve the agent's DELETE pendingAction through the workflow-edit save so its row stays suppressed.
Confidence
High confidence on the mechanism (the DELETE → UPDATE clobber un-hides the agent). The exact shape of the second card — whether it's a standalone group or the default workflow re-greyed with the agent re-added — depends on the agent's residual submitsTo value, which I traced statically rather than reproduced. Happy to confirm the precise rendering in-app if useful.
@MelvinBot pls implement your solution from here. Include automated tests, and also run a manual test in the web platform. Ensure you properly go through set up for manual testing like going through onboarding, creating a workspace, etc.
⏱️ Ran out of time before I could finish. This usually means the task was too complex or I got stuck exploring. Please try again with a more specific request or post in #melvinbot-ai.
Please re-state the problem that we are trying to solve in this issue.
On all platforms (Android, iOS, Web, Desktop), when a user deletes an agent while offline and then edits an existing approval workflow that referenced that agent (swapping the approver for another member and tapping Save), a greyed‑out phantom workflow row for the deleted agent appears in the Workflows list. The expected behavior is that the deleted agent's row stays hidden/marked DELETE and no extra workflow card is rendered.
What is the root cause of that problem?
The bug requires two functions working in tandem to reproduce: updateApprovalWorkflow in src/libs/actions/Workflow.ts and convertApprovalWorkflowToPolicyEmployees in src/libs/WorkflowUtils.ts.
Step 1 — updateApprovalWorkflow strips all DELETE markers before the converter ever runs.
When the user taps Save on the edited workflow, updateApprovalWorkflow (src/libs/actions/Workflow.ts:100-204) builds its previousEmployeeList snapshot on line 107:
This unconditionally sets pendingAction: null on every entry — including the deleted agent whose entry was carrying pendingAction: 'DELETE' (set optimistically by deleteAgent in src/libs/actions/Agent.ts). The sanitised previousEmployeeList (with DELETE erased) is then handed to convertApprovalWorkflowToPolicyEmployees.
Step 2 — the converter writes UPDATE onto the deleted agent's entry.
Inside convertApprovalWorkflowToPolicyEmployees (src/libs/WorkflowUtils.ts:345-437), the approversToRemove loop (lines 428–436) writes the deleted agent's email into updatedEmployees with pendingAction: pendingAction (which resolves to UPDATE for an edit). The approver loop at line 386 already has a DELETE-preserving guard:
but because previousEmployeeList arrived with pendingAction: null on every entry, previousPendingAction is always null here, so the guard never fires and the deleted agent gets pendingAction: UPDATE.
Step 3 — calculateApprovers emits the stale entry.
With the DELETE marker replaced by UPDATE (per the changes from PR #92286 that made calculateApprovers read pendingAction from policy.employeeList), the agent's entry is no longer filtered out and renders as a greyed‑out phantom workflow card.
What changes do you think we should make in order to solve the problem?
The fix has two parts: (1) stop updateApprovalWorkflow from nulling DELETE markers, and (2) add the matching guard inside the converter for the loops that currently lack it.
1. src/libs/actions/Workflow.ts:107 — Preserve DELETE pendingAction when building previousEmployeeList.
Change the previousEmployeeList construction so that entries with pendingAction: 'delete' keep their value; only non-DELETE entries are nulled out (which is the caller's intent — clearing stale UPDATE/ADD markers before a re-compute):
This is the primary fix. It ensures the DELETE marker set by deleteAgent survives into convertApprovalWorkflowToPolicyEmployees so the existing guard in the approvers loop (and the new guards below) can act on it.
2. src/libs/WorkflowUtils.ts:428-436 — Mirror the DELETE-preserving guard in the approversToRemove loop.
4. src/libs/WorkflowUtils.ts:395-412 — Apply the same guard in the members loop for parity.
The approvalWorkflow.members loop at lines 395–412 writes pendingAction unconditionally on every member entry whose submitsTo changed. Add the DELETE-preserving guard here too so the same offline-delete scenario on the member side does not resurrect a DELETE-pending row:
5. Add a WorkflowUtilsTest case covering the full offline-delete-then-edit path.
The test should assert: given previousEmployeeList[agentEmail].pendingAction === 'delete' and agentEmail ∈ approversToRemove, calling convertApprovalWorkflowToPolicyEmployees with type UPDATE must produce updatedEmployees[agentEmail].pendingAction === 'delete' (not 'update'). A companion integration test should verify that after updateApprovalWorkflow runs under the same conditions, the Onyx-merged policy.employeeList[agentEmail].pendingAction remains 'delete' and the agent does not appear in the output of calculateApprovers.
What alternative solutions did you explore? (Optional)
Filter out DELETE-pending entries inside calculateApprovers instead — rejected because the persisted policy.employeeList would still carry the wrong pendingAction: UPDATE after the offline edit and would diverge from the optimistic DELETE intent set by deleteAgent; fixing it at the write site keeps the Onyx state correct for every consumer.
Please re-state the problem that we are trying to solve in this issue.
After deleting an agent while offline and then editing the approval workflow that used that agent as approver (changing the approver to another member and saving), an extra greyed‑out workflow appears that still contains the deleted agent. Expected: no extra workflow appears.
What is the root cause of that problem?
When an agent is deleted while offline, deleteAgent optimistically marks the agent's row in every policy's employeeList with pendingAction: DELETE. The display path (convertPolicyEmployeesToApprovalWorkflows) correctly treats that row as pending‑delete — it excludes it from the members list and does not let the DELETE turn a workflow grey.
The problem is the save path that runs when the approval is edited. updateApprovalWorkflow builds the "previous" employee list it diffs against, and it force‑nulls the pendingAction of every employee:
This wipes the in‑flight DELETE off the deleted agent before the conversion even runs, which defeats the DELETE‑preservation guards that already exist downstream (they all check previousPendingAction === DELETE, but previousPendingAction is now always null).
On top of that, when the deleted agent is removed as the approver during the edit, it flows through the "approvers to remove" loop in convertApprovalWorkflowToPolicyEmployees, which assigns the ADD/UPDATE pending action unconditionally — it has no DELETE guard at all:
The combined effect: the agent's pendingAction is downgraded from DELETE to UPDATE. On the next render the agent is no longer treated as pending‑delete, so it is added back as a member of the workflow keyed by its submitsTo, and that workflow renders greyed‑out (pending update) — the extra greyed‑out workflow with the deleted agent.
What changes do you think we should make in order to solve the problem?
Preserve an in‑flight DELETE pending action through the entire approval‑workflow edit so a deleted agent stays flagged for deletion instead of being downgraded to UPDATE.
In updateApprovalWorkflow (and the sibling create/remove flows that build the same "previous" employee list), when clearing pending actions on the previous employee list, clear only ADD/UPDATE — keep a DELETE pending action intact. This makes the existing previousPendingAction === DELETE guards effective again.
In convertApprovalWorkflowToPolicyEmployees, add the same DELETE guard to the "members to remove" and "approvers to remove" loops that the main approvers loop already uses: when the previous pending action for that email is DELETE, keep DELETE rather than overwriting it with the ADD/UPDATE pending action.
With both in place, the deleted agent keeps its DELETE pending action across the edit, so convertPolicyEmployeesToApprovalWorkflows continues to exclude it and no greyed‑out workflow with the deleted agent is produced.
This was verified with a Jest test that drives updateApprovalWorkflow for the exact repro (an offline‑deleted agent removed as approver while editing the workflow) and asserts the agent's optimistic pendingAction stays DELETE. The test fails on main (the agent's pending action is update) and passes with the fix.
What alternative solutions did you explore? (Optional)
An alternative is to skip emitting any update entry for an employee whose previous pending action is DELETE (rather than preserving DELETE on the emitted entry), since a to‑be‑deleted agent does not need a forwardsTo/submitsTo reset sent to the server. Preserving the DELETE pending action was chosen instead because it mirrors the guard the main approvers loop already uses, keeps the optimistic employee state self‑consistent, and is the smaller, more localized change.
Please re-state the problem that we are trying to solve in this issue.
When an agent (or member) is deleted while offline and you then edit the approval workflow that used them as approver — swapping the approver for someone else and tapping Save — a phantom greyed‑out workflow still showing the deleted agent appears. Expected: the deleted agent stays hidden and no extra workflow card is rendered.
What is the root cause of that problem?
deleteAgent is offline‑safe: it can't actually remove the agent's employeeList row, so it optimistically marks that row pendingAction: DELETE on every policy (Agent.ts:362-373). The whole "hide the deleted approver" behaviour hangs on that DELETE marker surviving — convertPolicyEmployeesToApprovalWorkflows only excludes the row and suppresses its grey styling when pendingAction === DELETE (WorkflowUtils.ts:184, 233, 243-251).
The single root cause is Workflow.ts:107. When you save the edit, updateApprovalWorkflow builds the previousEmployeeList snapshot it diffs against and force‑nulls pendingAction on every employee:
The deleted agent's DELETE is wiped right here, before any conversion runs. I want to highlight evidence the other proposals missed: the codebase already tries to preserve DELETE in three places that all read previousEmployeeList[...].pendingAction === DELETE — the main approver loop (WorkflowUtils.ts:386) and the recently‑added default‑approver backstop (Workflow.ts:127-132). Both of those guards are dead code — line 107 guarantees previousPendingAction is always null by the time they run, so they never fire. The bug isn't "a missing guard"; it's that one upstream line silently defeats the guards the maintainers already wrote.
The second gap is in the conversion itself. In the repro the agent is removed as approver, so it flows through the approversToRemove loop — which, unlike the main loop, has no DELETE guard at all and overwrites the row with pendingAction: UPDATE (WorkflowUtils.ts:428-435); the membersToRemove loop has the same gap (416-423). That {forwardsTo: '', pendingAction: UPDATE} row is MERGEd into the policy, clobbering the DELETE. On the next render the agent is no longer DELETE‑suppressed and — still carrying the residual submitsTo the backend's shareWithEmployees gave it (see the comment at Workflow.ts:117-123) — renders as its own greyed grouping. That residual submitsTo is also the answer to @neil-marcellini's question: the "second workflow" is the deleted agent's own row resurfacing, keyed on its submitsTo at WorkflowUtils.ts:195, not a genuinely new workflow.
What changes do you think we should make in order to solve the problem?
1. Stop Workflow.ts:107 from nulling a DELETE marker. This is the primary fix — it instantly revives the existing guards at WorkflowUtils.ts:386 and Workflow.ts:132, and (critically) it is also what makes the failureData rollback at Workflow.ts:175-186 restore DELETE correctly if the request fails.
2. In the approversToRemove / membersToRemove loops, skip a row that is already pending DELETE rather than rewriting it. I deliberately differ from the other proposals here, which mirror the main loop's "preserve DELETE on the emitted row". Mirroring works for display, but it keeps the agent in updatedEmployees, and updatedEmployees drives two things it shouldn't: the API payload employees: JSON.stringify(...) (Workflow.ts:200) — sending a pointless forwardsTo reset for a row that DELETE_AGENT is about to delete — and, more importantly, the successData null‑clear (Workflow.ts:193). Both DELETE_AGENT and UPDATE_WORKSPACE_APPROVAL queue offline and resolve in order; DELETE_AGENT's success sets the row to null (Agent.ts:365/374), then UPDATE's success MERGEs {[agent]: {pendingAction: null, pendingFields: null}} back onto that just‑cleared key. The agent's lifecycle is owned by DELETE_AGENT; the workflow‑edit command should not be writing to its row at all. Skipping keeps the two commands' Onyx footprints disjoint:
if (approversToRemove) {
for (const {email} of approversToRemove) {
+ if (previousEmployeeList[email]?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) {+ continue;+ }
updatedEmployeeList[email] = {
...(updatedEmployeeList[email] ? updatedEmployeeList[email] : {email}),
forwardsTo: '',
pendingAction,
};
}
}
The same one‑line continue guard goes in the membersToRemove loop (416-423) for the member‑deleted variant @mkhutornyi reproduced.
With both in place: offline, the agent's DELETE row is left untouched by the edit, so convertPolicyEmployeesToApprovalWorkflows keeps excluding it → no phantom card and no double workflow. Online, UPDATE_WORKSPACE_APPROVAL no longer carries or re‑touches the deleted row, and DELETE_AGENT removes it cleanly. On failureData, fix #1 restores the DELETE so the row stays hidden after a rollback.
Tests. Add a WorkflowUtilsTest case asserting that, given previousEmployeeList[agent].pendingAction === 'delete' and agent ∈ approversToRemove, convertApprovalWorkflowToPolicyEmployees({type: UPDATE, ...}) does not emit an agent entry (so the optimistic MERGE leaves the existing DELETE intact). Plus an AgentActionTest/integration case driving updateApprovalWorkflow end‑to‑end for the exact repro and asserting policy.employeeList[agent].pendingAction stays 'delete' and the agent is absent from convertPolicyEmployeesToApprovalWorkflows output.
What alternative solutions did you explore? (Optional)
Preserve DELETE on the emitted row in the remove loops (the other proposals' approach). It fixes the visible bug, but as shown above it leaves the deleted agent inside updatedEmployees, so the workflow‑update command sends and later null‑clears a row that belongs to DELETE_AGENT's own success/failure lifecycle. Skipping is the smaller, more correct change — it never entangles the two commands.
Filter DELETE rows inside calculateApprovers/convertPolicyEmployeesToApprovalWorkflows only. Rejected: the persisted policy.employeeList would still carry the wrong UPDATE after the offline edit, diverging from the optimistic DELETE intent. Fixing it at the write site keeps Onyx correct for every consumer.
Revert #92286. This was the original deploy‑blocker escape hatch. No longer necessary now that agents are behind a beta and this is a forward‑fixable, well‑scoped change.
This is a regression from #92286 ("Handle agent deleted on approval workflow in offline mode", merged 06-10, one day before this was filed). That PR taught the display path to hide an employee whose employeeList row carries pendingAction: DELETE: convertPolicyEmployeesToApprovalWorkflows keeps a DELETE row out of availableMembers (WorkflowUtils.ts:184), never lets it grey a card (WorkflowUtils.ts:233, 249), and never adds it as a workflow member (WorkflowUtils.ts:243-245). deleteAgent stamps that marker on every policy's row optimistically (Agent.ts:354-373).
What #92286 did not touch is the workflow-edit save path. So when you edit the approver while the agent's optimistic DELETE is still in flight (i.e. offline), the save path overwrites DELETE with UPDATE, and the now-UPDATE row sails straight through every DELETE filter above and renders as a greyed card containing the deleted agent.
Two independent spots flip DELETE→UPDATE, and for the reported repro both have to be fixed:
updateApprovalWorkflow builds previousEmployeeList by force-nulling pendingAction on every row (Workflow.ts:107). The agent's DELETE is erased here before the converter even runs.
Swapping the approver away from the agent puts it into approversToRemove (WorkspaceWorkflowsApprovalsEditPage.tsx:107-110), and convertApprovalWorkflowToPolicyEmployees writes it back as {forwardsTo: '', pendingAction: UPDATE} (WorkflowUtils.ts:428-436). Unlike the main approver loop — which guards with prev === DELETE ? prev : UPDATE (WorkflowUtils.ts:380-386) — this loop sets pendingAction unconditionally and never reads the previous row at all.
They compound: fix only #1 and the approversToRemove loop still ignores previousEmployeeList and writes UPDATE; fix only #2 and its guard reads previousEmployeeList[email].pendingAction, which #1 already nulled. The resulting {employeeList: updatedEmployees} is MERGEd into the policy (Workflow.ts:165-172), clobbering the standing DELETE.
Same root cause explains the two greyed workflows mkhutornyi/neil saw: the resurrected agent row still carries the submitsTo the backend's shareWithEmployees gave it when it was promoted to approver (the old default approver). Since each card is keyed on submitsTo (WorkflowUtils.ts:195, 235), once it's no longer DELETE-suppressed it spawns its own greyed grouping next to the workflow you actually edited.
This isn't agent-specific. Removing a regular member also stamps pendingAction: DELETE on the employeeList row (Policy/Member.ts:378-381) — which is why mkhutornyi reproduced the identical thing with a workspace member in production. The defect is in the generic save path, not in agent code.
What changes do you think we should make in order to solve the problem?
Fix layer: optimistic-data construction (the action + the util), not display. The display path already handles DELETE correctly; the job is to stop the save path from destroying the marker.
Workflow.ts:107 — when building previousEmployeeList, keep pendingAction when it's DELETE and null it otherwise (pendingAction: value.pendingAction === DELETE ? value.pendingAction : null). This is the keystone: it re-arms the guard the approver loop already has and gives the remove-loop guard something truthful to read. It also flows into failureData (Workflow.ts:180), so an offline rollback correctly restores the in-flight DELETE.
WorkflowUtils.ts:428-436 (approversToRemove) — mirror the approver loop's guard: read previousEmployeeList[email]?.pendingAction and keep DELETE instead of overwriting it. This is the loop the reported repro actually goes through, so it's required alongside Some initial fixes and code style updates #1.
Parity (same class of bug): apply the identical guard to the membersToRemove loop (WorkflowUtils.ts:416-424) and the members loop (WorkflowUtils.ts:395-411). The reported repro only exercises approversToRemove, but a deleted member who is a plain submitter would hit membersToRemove with the same un-hiding result. Closing all three keeps one rule consistent: a pending-DELETE row is never downgraded to ADD/UPDATE.
Edge cases this actually touches: offline (the only window where the optimistic DELETE lives long enough to be clobbered) and the optimistic failure rollback (now restores DELETE). Online is unaffected — DELETE_AGENT / member-remove reconciles the row away on the server.
Test: a WorkflowUtilsTest case asserting that with previousEmployeeList[agent].pendingAction === 'delete' and agent ∈ approversToRemove, convertApprovalWorkflowToPolicyEmployees({type: UPDATE}) returns the agent with pendingAction === 'delete' (not 'update'); plus an integration-style check that after updateApprovalWorkflow the merged policy.employeeList[agent].pendingAction stays 'delete' and the agent produces no card from convertPolicyEmployeesToApprovalWorkflows. It should fail on the current SHA.
What alternative solutions did you explore? (Optional)
Filter DELETE rows harder in the display/consumer layer (e.g. drop them inside calculateApprovers / convertPolicyEmployeesToApprovalWorkflows). Rejected: the persisted optimistic employeeList[agent].pendingAction would still be wrong (update), diverging from what deleteAgent / member-remove intended, and the failureData rollback at Workflow.ts:180 plus every other reader of that row would inherit the wrong action. Fixing at the write site keeps Onyx self-consistent for all consumers.
Skip emitting an entry at all for an employee whose previous action is DELETE (don't bother sending a forwardsTo/submitsTo reset for a row that's being deleted). Reasonable and marginally smaller, but I prefer preserving DELETE on the emitted row — it mirrors the guard the approver loop already uses and avoids a special-case "no-op" branch.
Revert #92286 — the standard deploy-blocker escape hatch. Since this is already de-blockered (agents are beta-gated) and the production member variant is non-blocking, I'd rather land the forward fix than lose the offline strikethrough that PR added. Noting it only as the fallback if a fix can't land in time.
⚠️@yusufdeveloper2903 Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.
⚠️@Tony-MK Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.
Activity
applause-bot commentedon Jun 11, 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/7f84c17cea534f38c4647249a7b58f3c294888fd9ca78a22ddc47b54f17814c0
melvin-bot commentedon Jun 11, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #92286
melvin-bot commentedon Jun 11, 2026
💬 A slack conversation has been started in #expensify-open-source
github-actions commentedon Jun 11, 2026
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
MelvinBot commentedon Jun 11, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
After deleting an agent offline and then editing an approval workflow where that agent was the approver, a phantom greyed‑out workflow showing the deleted agent appears. This is a regression from #92286 (in this StagingDeployCash).
What is the root cause of that problem?
PR #92286 made
deleteAgentoptimistically mark the agent's row in every policyemployeeListwithpendingAction: DELETE, so the workflow UI strikes it through while the delete is in flight (Agent.ts:354-377). The whole strikethrough/hide behavior depends on thatDELETEmarker surviving —convertPolicyEmployeesToApprovalWorkflowsonly excludes a member and suppresses its pending styling whenpendingAction === DELETE(WorkflowUtils.ts:184-185,233,243-250).Saving an edited approval clobbers that
DELETEmarker toUPDATE, so the deleted agent is no longer hidden and instead renders as a greyed‑out (pending) workflow. Two spots in the save path do this:Where the DELETE pendingAction is lost
updateApprovalWorkflow—Workflow.ts:107buildspreviousEmployeeListby forcingpendingAction: nullon every employee. So theDELETE‑preserving ternary inside the convert helper (WorkflowUtils.ts:386) never seesDELETE.The
membersToRemove(WorkflowUtils.ts:416-424) andapproversToRemove(WorkflowUtils.ts:428-436) branches setpendingActionunconditionally toUPDATE— unlike the main approver loop, they have noDELETE‑preserving check at all.When the user swaps the approver away from the deleted agent, the agent goes into
approversToRemove, soupdatedEmployees[agent] = {forwardsTo: '', pendingAction: UPDATE}. That row is MERGEd into the policy'semployeeList, overwriting the existingDELETE. On recompute the agent now carriesUPDATE, which is not filtered/suppressed → greyed‑out phantom workflow.What changes do you think we should make in order to solve the problem?
Preserve the agent's
DELETEpendingAction through the workflow‑edit save so the existing hide/strikethrough logic keeps working:Workflow.ts:107, don't blanket‑nullpendingAction; keep it when it'sDELETE(e.g.pendingAction: value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE ? value.pendingAction : null).membersToRemoveandapproversToRemovebranches ofconvertApprovalWorkflowToPolicyEmployees, mirror the main loop's guard so a previousDELETEis retained instead of overwritten withUPDATE.A pending‑delete agent should never be re‑written with an
ADD/UPDATEpendingAction. Add a unit test inWorkflowUtilsTest/AgentActionTestcovering "edit approver while an approver row is pending‑delete".What alternative solutions did you explore? (Optional)
Because this is a time‑sensitive deploy blocker, reverting #92286 is the fastest way to unblock the deploy if a forward fix can't land quickly — the offline strikethrough is a nice‑to‑have, and reverting removes the
DELETEmarker that the save path mishandles.Confidence & verification
High confidence from static tracing of the data flow (Onyx optimistic MERGE → workflow recompute). Not reproduced in a running app. The mechanism explains all symptoms: offline‑only (optimistic data persists, never reconciled by server), greyed‑out (pendingAction styling), and "deleted agent reappears" (DELETE → UPDATE flip un‑hides the row).
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/93260)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
neil-marcellini commentedon Jun 11, 2026
@MelvinBot why are there also two approval workflows after updating the approver in one workflow from the deleted agent to another user while offline?
mkhutornyi commentedon Jun 11, 2026
I reproduced the same bug (workspace member instead of agent) in production. Not blocker.
Repro step:
bug.mov
MelvinBot commentedon Jun 11, 2026
Same root cause as above — the second workflow is the deleted agent resurfacing, not a real new workflow.
Offline, deleting the agent never actually removes its
employeeListrow; it only marks it. PR #92286 sets that row topendingAction: DELETE, and the workflows page relies onDELETEto hide the row (it's filtered out ofavailableMembers/membersand not allowed to spawn or grey a workflow —WorkflowUtils.ts:184,233,243,249).When you change the approver and save, the agent goes into
approversToRemoveand its row is re-written withpendingAction: UPDATE(WorkflowUtils.ts:428-436; theDELETEis also already discarded one step earlier atWorkflow.ts:107, which nulls every row'spendingAction). ThatUPDATErow is MERGEd into the policy, overwriting theDELETEmarker that was keeping the agent hidden.So now there are two cards:
DELETE-suppressed, and it still carries thesubmitsTothe backend'sshareWithEmployeesgave it when the agent was promoted to approver (the previous default approver — see the comment atWorkflow.ts:117-123). Since each workflow card is keyed on an employee'ssubmitsTo(WorkflowUtils.ts:195), that residualsubmitsTomakes the resurrected agent render as its own greyed grouping instead of staying hidden.Both cards are greyed because both rows carry a pending action while you're offline.
The fix in my analysis above resolves this too: preserve the agent's
DELETEpendingAction through the workflow-edit save so its row stays suppressed.Confidence
High confidence on the mechanism (the
DELETE → UPDATEclobber un-hides the agent). The exact shape of the second card — whether it's a standalone group or the default workflow re-greyed with the agent re-added — depends on the agent's residualsubmitsTovalue, which I traced statically rather than reproduced. Happy to confirm the precise rendering in-app if useful.neil-marcellini commentedon Jun 11, 2026
@MelvinBot pls implement your solution from here. Include automated tests, and also run a manual test in the web platform. Ensure you properly go through set up for manual testing like going through onboarding, creating a workspace, etc.
6 remaining items
mkhutornyi commentedon Jun 11, 2026
Assign me here too
MelvinBot commentedon Jun 11, 2026
⏱️ Ran out of time before I could finish. This usually means the task was too complex or I got stuck exploring. Please try again with a more specific request or post in #melvinbot-ai.
Run details
aswin-s commentedon Jun 11, 2026
Please re-state the problem that we are trying to solve in this issue.
On all platforms (Android, iOS, Web, Desktop), when a user deletes an agent while offline and then edits an existing approval workflow that referenced that agent (swapping the approver for another member and tapping Save), a greyed‑out phantom workflow row for the deleted agent appears in the Workflows list. The expected behavior is that the deleted agent's row stays hidden/marked DELETE and no extra workflow card is rendered.
What is the root cause of that problem?
The bug requires two functions working in tandem to reproduce:
updateApprovalWorkflowinsrc/libs/actions/Workflow.tsandconvertApprovalWorkflowToPolicyEmployeesinsrc/libs/WorkflowUtils.ts.Step 1 —
updateApprovalWorkflowstrips all DELETE markers before the converter ever runs.When the user taps Save on the edited workflow,
updateApprovalWorkflow(src/libs/actions/Workflow.ts:100-204) builds itspreviousEmployeeListsnapshot on line 107:This unconditionally sets
pendingAction: nullon every entry — including the deleted agent whose entry was carryingpendingAction: 'DELETE'(set optimistically bydeleteAgentinsrc/libs/actions/Agent.ts). The sanitisedpreviousEmployeeList(with DELETE erased) is then handed toconvertApprovalWorkflowToPolicyEmployees.Step 2 — the converter writes UPDATE onto the deleted agent's entry.
Inside
convertApprovalWorkflowToPolicyEmployees(src/libs/WorkflowUtils.ts:345-437), theapproversToRemoveloop (lines 428–436) writes the deleted agent's email intoupdatedEmployeeswithpendingAction: pendingAction(which resolves toUPDATEfor an edit). The approver loop at line 386 already has a DELETE-preserving guard:but because
previousEmployeeListarrived withpendingAction: nullon every entry,previousPendingActionis alwaysnullhere, so the guard never fires and the deleted agent getspendingAction: UPDATE.Step 3 —
calculateApproversemits the stale entry.With the DELETE marker replaced by UPDATE (per the changes from PR #92286 that made
calculateApproversreadpendingActionfrompolicy.employeeList), the agent's entry is no longer filtered out and renders as a greyed‑out phantom workflow card.What changes do you think we should make in order to solve the problem?
The fix has two parts: (1) stop
updateApprovalWorkflowfrom nulling DELETE markers, and (2) add the matching guard inside the converter for the loops that currently lack it.1.
src/libs/actions/Workflow.ts:107— Preserve DELETEpendingActionwhen buildingpreviousEmployeeList.Change the
previousEmployeeListconstruction so that entries withpendingAction: 'delete'keep their value; only non-DELETE entries are nulled out (which is the caller's intent — clearing stale UPDATE/ADD markers before a re-compute):This is the primary fix. It ensures the DELETE marker set by
deleteAgentsurvives intoconvertApprovalWorkflowToPolicyEmployeesso the existing guard in the approvers loop (and the new guards below) can act on it.2.
src/libs/WorkflowUtils.ts:428-436— Mirror the DELETE-preserving guard in theapproversToRemoveloop.3.
src/libs/WorkflowUtils.ts:416-424— Apply the same guard to themembersToRemoveloop.4.
src/libs/WorkflowUtils.ts:395-412— Apply the same guard in themembersloop for parity.The
approvalWorkflow.membersloop at lines 395–412 writespendingActionunconditionally on every member entry whosesubmitsTochanged. Add the DELETE-preserving guard here too so the same offline-delete scenario on the member side does not resurrect a DELETE-pending row:5. Add a
WorkflowUtilsTestcase covering the full offline-delete-then-edit path.The test should assert: given
previousEmployeeList[agentEmail].pendingAction === 'delete'andagentEmail ∈ approversToRemove, callingconvertApprovalWorkflowToPolicyEmployeeswith typeUPDATEmust produceupdatedEmployees[agentEmail].pendingAction === 'delete'(not'update'). A companion integration test should verify that afterupdateApprovalWorkflowruns under the same conditions, the Onyx-mergedpolicy.employeeList[agentEmail].pendingActionremains'delete'and the agent does not appear in the output ofcalculateApprovers.What alternative solutions did you explore? (Optional)
Filter out DELETE-pending entries inside
calculateApproversinstead — rejected because the persistedpolicy.employeeListwould still carry the wrongpendingAction: UPDATEafter the offline edit and would diverge from the optimistic DELETE intent set bydeleteAgent; fixing it at the write site keeps the Onyx state correct for every consumer.wildan-m commentedon Jun 11, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
After deleting an agent while offline and then editing the approval workflow that used that agent as approver (changing the approver to another member and saving), an extra greyed‑out workflow appears that still contains the deleted agent. Expected: no extra workflow appears.
What is the root cause of that problem?
When an agent is deleted while offline,
deleteAgentoptimistically marks the agent's row in every policy'semployeeListwithpendingAction: DELETE. The display path (convertPolicyEmployeesToApprovalWorkflows) correctly treats that row as pending‑delete — it excludes it from the members list and does not let the DELETE turn a workflow grey.The problem is the save path that runs when the approval is edited.
updateApprovalWorkflowbuilds the "previous" employee list it diffs against, and it force‑nulls thependingActionof every employee:App/src/libs/actions/Workflow.ts
Line 107 in 1ce07c3
This wipes the in‑flight DELETE off the deleted agent before the conversion even runs, which defeats the DELETE‑preservation guards that already exist downstream (they all check
previousPendingAction === DELETE, butpreviousPendingActionis now always null).On top of that, when the deleted agent is removed as the approver during the edit, it flows through the "approvers to remove" loop in
convertApprovalWorkflowToPolicyEmployees, which assigns the ADD/UPDATE pending action unconditionally — it has no DELETE guard at all:App/src/libs/WorkflowUtils.ts
Lines 426 to 435 in 1ce07c3
The combined effect: the agent's
pendingActionis downgraded from DELETE to UPDATE. On the next render the agent is no longer treated as pending‑delete, so it is added back as a member of the workflow keyed by itssubmitsTo, and that workflow renders greyed‑out (pending update) — the extra greyed‑out workflow with the deleted agent.What changes do you think we should make in order to solve the problem?
Preserve an in‑flight DELETE pending action through the entire approval‑workflow edit so a deleted agent stays flagged for deletion instead of being downgraded to UPDATE.
updateApprovalWorkflow(and the sibling create/remove flows that build the same "previous" employee list), when clearing pending actions on the previous employee list, clear only ADD/UPDATE — keep a DELETE pending action intact. This makes the existingpreviousPendingAction === DELETEguards effective again.App/src/libs/actions/Workflow.ts
Line 107 in 1ce07c3
convertApprovalWorkflowToPolicyEmployees, add the same DELETE guard to the "members to remove" and "approvers to remove" loops that the main approvers loop already uses: when the previous pending action for that email is DELETE, keep DELETE rather than overwriting it with the ADD/UPDATE pending action.App/src/libs/WorkflowUtils.ts
Lines 414 to 436 in 1ce07c3
With both in place, the deleted agent keeps its DELETE pending action across the edit, so
convertPolicyEmployeesToApprovalWorkflowscontinues to exclude it and no greyed‑out workflow with the deleted agent is produced.This was verified with a Jest test that drives
updateApprovalWorkflowfor the exact repro (an offline‑deleted agent removed as approver while editing the workflow) and asserts the agent's optimisticpendingActionstays DELETE. The test fails onmain(the agent's pending action isupdate) and passes with the fix.Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/93260-preserve-delete-pending-on-workflow-edit?expand=1
What alternative solutions did you explore? (Optional)
An alternative is to skip emitting any update entry for an employee whose previous pending action is DELETE (rather than preserving DELETE on the emitted entry), since a to‑be‑deleted agent does not need a
forwardsTo/submitsToreset sent to the server. Preserving the DELETE pending action was chosen instead because it mirrors the guard the main approvers loop already uses, keeps the optimistic employee state self‑consistent, and is the smaller, more localized change.yusufdeveloper2903 commentedon Jun 11, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When an agent (or member) is deleted while offline and you then edit the approval workflow that used them as approver — swapping the approver for someone else and tapping Save — a phantom greyed‑out workflow still showing the deleted agent appears. Expected: the deleted agent stays hidden and no extra workflow card is rendered.
What is the root cause of that problem?
deleteAgentis offline‑safe: it can't actually remove the agent'semployeeListrow, so it optimistically marks that rowpendingAction: DELETEon every policy (Agent.ts:362-373). The whole "hide the deleted approver" behaviour hangs on thatDELETEmarker surviving —convertPolicyEmployeesToApprovalWorkflowsonly excludes the row and suppresses its grey styling whenpendingAction === DELETE(WorkflowUtils.ts:184,233,243-251).The single root cause is
Workflow.ts:107. When you save the edit,updateApprovalWorkflowbuilds thepreviousEmployeeListsnapshot it diffs against and force‑nullspendingActionon every employee:The deleted agent's
DELETEis wiped right here, before any conversion runs. I want to highlight evidence the other proposals missed: the codebase already tries to preserveDELETEin three places that all readpreviousEmployeeList[...].pendingAction === DELETE— the main approver loop (WorkflowUtils.ts:386) and the recently‑added default‑approver backstop (Workflow.ts:127-132). Both of those guards are dead code — line 107 guaranteespreviousPendingActionis alwaysnullby the time they run, so they never fire. The bug isn't "a missing guard"; it's that one upstream line silently defeats the guards the maintainers already wrote.The second gap is in the conversion itself. In the repro the agent is removed as approver, so it flows through the
approversToRemoveloop — which, unlike the main loop, has noDELETEguard at all and overwrites the row withpendingAction: UPDATE(WorkflowUtils.ts:428-435); themembersToRemoveloop has the same gap (416-423). That{forwardsTo: '', pendingAction: UPDATE}row is MERGEd into the policy, clobbering theDELETE. On the next render the agent is no longerDELETE‑suppressed and — still carrying the residualsubmitsTothe backend'sshareWithEmployeesgave it (see the comment atWorkflow.ts:117-123) — renders as its own greyed grouping. That residualsubmitsTois also the answer to @neil-marcellini's question: the "second workflow" is the deleted agent's own row resurfacing, keyed on itssubmitsToatWorkflowUtils.ts:195, not a genuinely new workflow.What changes do you think we should make in order to solve the problem?
1. Stop
Workflow.ts:107from nulling aDELETEmarker. This is the primary fix — it instantly revives the existing guards atWorkflowUtils.ts:386andWorkflow.ts:132, and (critically) it is also what makes thefailureDatarollback atWorkflow.ts:175-186restoreDELETEcorrectly if the request fails.2. In the
approversToRemove/membersToRemoveloops, skip a row that is already pendingDELETErather than rewriting it. I deliberately differ from the other proposals here, which mirror the main loop's "preserveDELETEon the emitted row". Mirroring works for display, but it keeps the agent inupdatedEmployees, andupdatedEmployeesdrives two things it shouldn't: the API payloademployees: JSON.stringify(...)(Workflow.ts:200) — sending a pointlessforwardsToreset for a row thatDELETE_AGENTis about to delete — and, more importantly, thesuccessDatanull‑clear (Workflow.ts:193). BothDELETE_AGENTandUPDATE_WORKSPACE_APPROVALqueue offline and resolve in order;DELETE_AGENT's success sets the row tonull(Agent.ts:365/374), thenUPDATE's success MERGEs{[agent]: {pendingAction: null, pendingFields: null}}back onto that just‑cleared key. The agent's lifecycle is owned byDELETE_AGENT; the workflow‑edit command should not be writing to its row at all. Skipping keeps the two commands' Onyx footprints disjoint:if (approversToRemove) { for (const {email} of approversToRemove) { + if (previousEmployeeList[email]?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) { + continue; + } updatedEmployeeList[email] = { ...(updatedEmployeeList[email] ? updatedEmployeeList[email] : {email}), forwardsTo: '', pendingAction, }; } }The same one‑line
continueguard goes in themembersToRemoveloop (416-423) for the member‑deleted variant @mkhutornyi reproduced.With both in place: offline, the agent's
DELETErow is left untouched by the edit, soconvertPolicyEmployeesToApprovalWorkflowskeeps excluding it → no phantom card and no double workflow. Online,UPDATE_WORKSPACE_APPROVALno longer carries or re‑touches the deleted row, andDELETE_AGENTremoves it cleanly. OnfailureData, fix #1 restores theDELETEso the row stays hidden after a rollback.Tests. Add a
WorkflowUtilsTestcase asserting that, givenpreviousEmployeeList[agent].pendingAction === 'delete'andagent ∈ approversToRemove,convertApprovalWorkflowToPolicyEmployees({type: UPDATE, ...})does not emit anagententry (so the optimistic MERGE leaves the existingDELETEintact). Plus anAgentActionTest/integration case drivingupdateApprovalWorkflowend‑to‑end for the exact repro and assertingpolicy.employeeList[agent].pendingActionstays'delete'and the agent is absent fromconvertPolicyEmployeesToApprovalWorkflowsoutput.What alternative solutions did you explore? (Optional)
DELETEon the emitted row in the remove loops (the other proposals' approach). It fixes the visible bug, but as shown above it leaves the deleted agent insideupdatedEmployees, so the workflow‑update command sends and later null‑clears a row that belongs toDELETE_AGENT's own success/failure lifecycle. Skipping is the smaller, more correct change — it never entangles the two commands.DELETErows insidecalculateApprovers/convertPolicyEmployeesToApprovalWorkflowsonly. Rejected: the persistedpolicy.employeeListwould still carry the wrongUPDATEafter the offline edit, diverging from the optimisticDELETEintent. Fixing it at the write site keeps Onyx correct for every consumer.Abdulloh0109 commentedon Jun 11, 2026
What is the root cause of that problem?
This is a regression from #92286 ("Handle agent deleted on approval workflow in offline mode", merged 06-10, one day before this was filed). That PR taught the display path to hide an employee whose
employeeListrow carriespendingAction: DELETE:convertPolicyEmployeesToApprovalWorkflowskeeps a DELETE row out ofavailableMembers(WorkflowUtils.ts:184), never lets it grey a card (WorkflowUtils.ts:233, 249), and never adds it as a workflow member (WorkflowUtils.ts:243-245).deleteAgentstamps that marker on every policy's row optimistically (Agent.ts:354-373).What #92286 did not touch is the workflow-edit save path. So when you edit the approver while the agent's optimistic DELETE is still in flight (i.e. offline), the save path overwrites DELETE with UPDATE, and the now-UPDATE row sails straight through every DELETE filter above and renders as a greyed card containing the deleted agent.
Two independent spots flip DELETE→UPDATE, and for the reported repro both have to be fixed:
updateApprovalWorkflowbuildspreviousEmployeeListby force-nullingpendingActionon every row (Workflow.ts:107). The agent's DELETE is erased here before the converter even runs.Swapping the approver away from the agent puts it into
approversToRemove(WorkspaceWorkflowsApprovalsEditPage.tsx:107-110), andconvertApprovalWorkflowToPolicyEmployeeswrites it back as{forwardsTo: '', pendingAction: UPDATE}(WorkflowUtils.ts:428-436). Unlike the main approver loop — which guards withprev === DELETE ? prev : UPDATE(WorkflowUtils.ts:380-386) — this loop setspendingActionunconditionally and never reads the previous row at all.They compound: fix only #1 and the
approversToRemoveloop still ignorespreviousEmployeeListand writes UPDATE; fix only #2 and its guard readspreviousEmployeeList[email].pendingAction, which #1 already nulled. The resulting{employeeList: updatedEmployees}is MERGEd into the policy (Workflow.ts:165-172), clobbering the standing DELETE.Same root cause explains the two greyed workflows mkhutornyi/neil saw: the resurrected agent row still carries the
submitsTothe backend'sshareWithEmployeesgave it when it was promoted to approver (the old default approver). Since each card is keyed onsubmitsTo(WorkflowUtils.ts:195, 235), once it's no longer DELETE-suppressed it spawns its own greyed grouping next to the workflow you actually edited.This isn't agent-specific. Removing a regular member also stamps
pendingAction: DELETEon theemployeeListrow (Policy/Member.ts:378-381) — which is why mkhutornyi reproduced the identical thing with a workspace member in production. The defect is in the generic save path, not in agent code.What changes do you think we should make in order to solve the problem?
Fix layer: optimistic-data construction (the action + the util), not display. The display path already handles DELETE correctly; the job is to stop the save path from destroying the marker.
Workflow.ts:107 — when building
previousEmployeeList, keeppendingActionwhen it's DELETE and null it otherwise (pendingAction: value.pendingAction === DELETE ? value.pendingAction : null). This is the keystone: it re-arms the guard the approver loop already has and gives the remove-loop guard something truthful to read. It also flows intofailureData(Workflow.ts:180), so an offline rollback correctly restores the in-flight DELETE.WorkflowUtils.ts:428-436 (
approversToRemove) — mirror the approver loop's guard: readpreviousEmployeeList[email]?.pendingActionand keep DELETE instead of overwriting it. This is the loop the reported repro actually goes through, so it's required alongside Some initial fixes and code style updates #1.Parity (same class of bug): apply the identical guard to the
membersToRemoveloop (WorkflowUtils.ts:416-424) and themembersloop (WorkflowUtils.ts:395-411). The reported repro only exercisesapproversToRemove, but a deleted member who is a plain submitter would hitmembersToRemovewith the same un-hiding result. Closing all three keeps one rule consistent: a pending-DELETE row is never downgraded to ADD/UPDATE.Edge cases this actually touches: offline (the only window where the optimistic DELETE lives long enough to be clobbered) and the optimistic failure rollback (now restores DELETE). Online is unaffected — DELETE_AGENT / member-remove reconciles the row away on the server.
Test: a
WorkflowUtilsTestcase asserting that withpreviousEmployeeList[agent].pendingAction === 'delete'andagent ∈ approversToRemove,convertApprovalWorkflowToPolicyEmployees({type: UPDATE})returns the agent withpendingAction === 'delete'(not'update'); plus an integration-style check that afterupdateApprovalWorkflowthe mergedpolicy.employeeList[agent].pendingActionstays'delete'and the agent produces no card fromconvertPolicyEmployeesToApprovalWorkflows. It should fail on the current SHA.What alternative solutions did you explore? (Optional)
Filter DELETE rows harder in the display/consumer layer (e.g. drop them inside
calculateApprovers/convertPolicyEmployeesToApprovalWorkflows). Rejected: the persisted optimisticemployeeList[agent].pendingActionwould still be wrong (update), diverging from whatdeleteAgent/ member-remove intended, and thefailureDatarollback at Workflow.ts:180 plus every other reader of that row would inherit the wrong action. Fixing at the write site keeps Onyx self-consistent for all consumers.Skip emitting an entry at all for an employee whose previous action is DELETE (don't bother sending a
forwardsTo/submitsToreset for a row that's being deleted). Reasonable and marginally smaller, but I prefer preserving DELETE on the emitted row — it mirrors the guard the approver loop already uses and avoids a special-case "no-op" branch.Revert #92286 — the standard deploy-blocker escape hatch. Since this is already de-blockered (agents are beta-gated) and the production member variant is non-blocking, I'd rather land the forward fix than lose the offline strikethrough that PR added. Noting it only as the fallback if a fix can't land in time.
github-actions commentedon Jun 11, 2026
github-actions commentedon Jun 12, 2026
NicolasBonet commentedon Jun 12, 2026
Closing per: #93315