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
Default workflow is not shown after deleting agent approver and duplicating workspace offline #93302
Version Number: 9.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+sdjonisdji12d@applause.expensifail.com Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Mac 26.5 / Chrome App Component: Workspace Settings
Action Performed:
Precondition:
Log in with Expensifail account.
Create a Control workspace.
Go to staging.new.expensify.com
Go to Account > Agents.
Create an agent.
Go to workspace settings > Workflows.
Click Add agent on the default workflow > Save.
Go to Account > Agents.
Go offline.
Delete the agent.
Go to Workspaces tab.
Click 3-dot menu next to the workspace.
Click Duplicate workspace.
Click Next > Continue.
Open the duplicated workspace.
Go to Workflows.
Expected Result:
Default workflow will be shown after deleting agent approver and duplicating workspace offline.
Actual Result:
Default workflow is not shown after deleting agent approver and duplicating workspace offline.
👋 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.
Regression from PR #92286 (this issue's deploy blocker). Confidence: High — fully traced through the offline flow with code evidence.
What is the root cause of that problem?
Deleting the agent leaves two stale references to it that the workspace‑duplication flow then copies into a policy where the agent no longer exists, so the default workflow can't be reconstructed.
Step by step:
Adding the agent as the default‑workflow approver sets policy.approver = agent and points the owner's submitsTo at the agent (Workflow.ts:106, Workflow.ts:170).
Deleting the agent (the behavior PR #92286 added) only marks the agent's ownemployeeList row pendingAction: DELETE (Agent.ts:351‑378). It does not clean up policy.approver or the owner's submitsTo, which both still point at the agent. (Fine so far — the agent's row still exists, so the chain resolves and the original workspace still renders the workflow.)
Duplicating the workspace offline strips the agent's row via the pre‑existing filterPendingDeleteData (Policy.ts:3290‑3304), but copies policy.approver and the owner's submitsToverbatim (Policy.ts:3313) — both now dangling at a removed employee.
Building the workflow cards, the owner's submitsTo points at the missing agent, so the guard at WorkflowUtils.ts:188continues and zero workflows are produced. The default‑workflow fallback is gated on at least one workflow already existing (WorkflowUtils.ts:268‑275), so it never fires → the default workflow card disappears.
Before PR #92286, agent deletion didn't mark the employeeList row, so the agent survived duplication and the chain resolved — which is why this is reproducible only on staging.
Why "not reproducible in production" and other supporting detail
This is purely an optimistic/offline display bug. Online, DELETE_AGENT runs before DUPLICATE_WORKSPACE; the backend removes the agent and cleans up its references on the source policy before the copy is made, so the duplicate is consistent. The breakage only exists in the offline-queued optimistic state.
getDefaultApprover returns policy.approver || policy.owner (PolicyUtils.ts:1414) — since policy.approver is still set to the (now-missing) agent, it never falls back to the owner.
buildOptimisticDuplicatePolicy performs no dangling-reference cleanup — it filters rows but never resets approver/submitsTo/forwardsTo that point at filtered-out employees.
What changes do you think we should make in order to solve the problem?
Primary (root-cause): In buildOptimisticDuplicatePolicy, after filtering pending‑delete employees, repair references to the removed rows in the duplicated policy:
if policy.approver points at a filtered‑out employee, reset it to the owner, and
reset any surviving employee's submitsTo/forwardsTo that points at a filtered‑out employee.
This keeps the duplicated policy internally consistent (and matches what the backend would produce).
Complementary hardening: Make convertPolicyEmployeesToApprovalWorkflows always emit a default workflow even when zero workflows are derived (resolving the default approver to the owner when policy.approver references a non‑existent employee). The default workflow should always be visible regardless of employeeList inconsistencies.
What alternative solutions did you explore? (Optional)
Revert PR #92286 — fastest way to unblock the deploy, since it removes the optimistic employeeList DELETE marking that triggers the filter. Trade‑off: loses the agent strikethrough/RBR display that PR added.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/93302) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
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/06b6ae7cd1367a0e46e3ab614eb356e3987c3b13ee787023ae95ee85f78f7595
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
What is the root cause of that problem?
Deleting the agent leaves two stale references to it that the workspace‑duplication flow then copies into a policy where the agent no longer exists, so the default workflow can't be reconstructed.
Step by step:
policy.approver = agentand points the owner'ssubmitsToat the agent (Workflow.ts:106, Workflow.ts:170).employeeListrowpendingAction: DELETE(Agent.ts:351‑378). It does not clean uppolicy.approveror the owner'ssubmitsTo, which both still point at the agent. (Fine so far — the agent's row still exists, so the chain resolves and the original workspace still renders the workflow.)filterPendingDeleteData(Policy.ts:3290‑3304), but copiespolicy.approverand the owner'ssubmitsToverbatim (Policy.ts:3313) — both now dangling at a removed employee.submitsTopoints at the missing agent, so the guard at WorkflowUtils.ts:188continues and zero workflows are produced. The default‑workflow fallback is gated on at least one workflow already existing (WorkflowUtils.ts:268‑275), so it never fires → the default workflow card disappears.Before PR #92286, agent deletion didn't mark the
employeeListrow, so the agent survived duplication and the chain resolved — which is why this is reproducible only on staging.Why "not reproducible in production" and other supporting detail
DELETE_AGENTruns beforeDUPLICATE_WORKSPACE; the backend removes the agent and cleans up its references on the source policy before the copy is made, so the duplicate is consistent. The breakage only exists in the offline-queued optimistic state.getDefaultApproverreturnspolicy.approver || policy.owner(PolicyUtils.ts:1414) — sincepolicy.approveris still set to the (now-missing) agent, it never falls back to the owner.buildOptimisticDuplicatePolicyperforms no dangling-reference cleanup — it filters rows but never resetsapprover/submitsTo/forwardsTothat point at filtered-out employees.What changes do you think we should make in order to solve the problem?
Primary (root-cause): In
buildOptimisticDuplicatePolicy, after filtering pending‑delete employees, repair references to the removed rows in the duplicated policy:policy.approverpoints at a filtered‑out employee, reset it to the owner, andsubmitsTo/forwardsTothat points at a filtered‑out employee.This keeps the duplicated policy internally consistent (and matches what the backend would produce).
Complementary hardening: Make
convertPolicyEmployeesToApprovalWorkflowsalways emit a default workflow even when zero workflows are derived (resolving the default approver to the owner whenpolicy.approverreferences a non‑existent employee). The default workflow should always be visible regardless ofemployeeListinconsistencies.What alternative solutions did you explore? (Optional)
Revert PR #92286 — fastest way to unblock the deploy, since it removes the optimistic
employeeListDELETE marking that triggers the filter. Trade‑off: loses the agent strikethrough/RBR display that PR added.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/93302)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
NicolasBonet commentedon Jun 11, 2026
Behind beta, so not a blocker
NicolasBonet commentedon Jun 12, 2026
Closing per #93330