Skip to content

Workspace - Approval workflow appears to save in New Expensify, then disappears without persisting to the backend. #99208

Closed

Description

@izarutskaya

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


Version Number:
Reproducible in staging?: Needs Reproduction (Unable to check with account customer's)
Reproducible in production?: Needs Reproduction (Unable to check with account customer's)
If this was caught during regression testing, add the test name, ID and link from BrowserStack:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @Leeckhart
Slack conversation (hyperlinked to channel name): #expensify_bugs

Action Performed:

  1. Open Workspace X in New Expensify.
  2. Go to Workflows.
  3. Edit/create an approval workflow.
  4. Add Employee 1 as the employee whose expenses should follow the workflow.
  • Configure:
  • First approver: Employee 2
  • Second approver: Employee 3
  1. Click Save
  2. The workflow appears to save successfully in the UI.
  3. Navigate away / return to the workflow page.
  4. The saved employee/workflow configuration has disappeared.

Expected Result:

The workflow should persist after clicking Save, and the configured employee/approvers should remain assigned after navigating away, refreshing, or reopening the workflow.

Actual Result:

The workflow appears to save successfully in the UI, but the changes later disappear.

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

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

Screenshots/Videos

For the customer's details check please the OP

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @FitseTLT

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Aug 21, 2026
  2. exfy-zapier commented on Aug 21, 2026

    @exfy-zapier

    This has been labelled "Needs Reproduction". Follow the steps here: https://stackoverflowteams.com/c/expensify/questions/16989

  3. FitseTLT commented on Aug 21, 2026

    @FitseTLT
    Contributor

    @mallenexpensify U can assign me I can reproduce it

    2026-08-21.20-46-07.mp4
  4. MelvinBot commented on Aug 21, 2026

    @MelvinBot
    Contributor

    Proposal

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

    An approval workflow (Workspace → Workflows → approvals) appears to save in the UI, but the configured member/approvers disappear after navigating away, refreshing, or reopening the Workflows page.

    What is the root cause of that problem?

    I could not reproduce a plain single-approver save (it persisted correctly across navigation in a fresh Collect workspace on web), so this is most likely an edge case tied to how the approver's email resolves, not a blanket save failure.

    The Workflows list is not read from a stored "workflows" object — it is re-derived from policy.employeeList every time the page renders, via convertPolicyEmployeesToApprovalWorkflows. That function silently drops any member whose submitsTo (the approver email) is not an exact key in employeeList:

    So even when the save persists on the backend, the workflow vanishes on the list if the stored approver email doesn't exactly match an employeeList key — e.g. a phone-number approver (e164@expensify.sms vs a raw phone string), a casing difference, or a freshly-invited approver not yet in the list. This exact failure mode is documented in the code:

    Other mechanisms considered (and why they're less likely)
    • Silent early-return with no API call — Workflow.ts:51-53 returns before API.write if the computed employee delta is empty, and the Save handler dismisses the modal regardless (WorkspaceWorkflowsApprovalsCreatePage.tsx:56-69). Possible, but for a genuinely new distinct-approver config the delta is non-empty, so the write does fire.
    • failureData revert on API error — Workflow.ts:71-80 rolls employeeList back if CreateWorkspaceApproval/UpdateWorkspaceApproval returns an error — would also look like "saved then disappeared." Needs logs to confirm.
    • Backend delta persistence — only the changed employees are sent (employees: JSON.stringify(Object.values(updatedEmployees))). If the backend CreateWorkspaceApproval/UpdateWorkspaceApproval (Web-Expensify) doesn't fully persist a delta-only payload, the read-back would drop it. This would be a backend fix, outside the App repo.

    Confidence: medium. Code evidence points to the read-back drop as the leading cause, but it wasn't reproduced in the basic case and there is no production confirmation yet. This customer report is still Needs Reproduction — knowing whether the approvers were phone-number logins or freshly-invited members would confirm or rule out the top hypothesis.

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

    1. Make the read-back resilient: in convertPolicyEmployeesToApprovalWorkflows, canonicalize submitsTo/forwardsTo (apply addSMSDomainIfPhoneNumber + normalize casing) before the employees[submitsTo] lookup so a phone/casing mismatch no longer drops the whole workflow, and don't silently continue — surface it instead of hiding it.
    2. Guarantee the approver email is stored in canonical form on save (the ApproverPage already does this at line 186; verify the same canonicalization is applied on the member/create paths).

    If reproduction confirms the write itself is failing or reverting (mechanisms 2/3 above), the fix would instead be on the backend CreateWorkspaceApproval/UpdateWorkspaceApproval persistence, which is outside the App repo and should be escalated to an internal engineer with Web-Expensify access.

    What alternative solutions did you explore?

    Confirming via production logs which submitsTo/forwardsTo emails were stored for the affected policy vs the employeeList keys returned on the next OpenApp/ReconnectApp, and the jsonCode of the save command, would disambiguate the App-side read-back drop from a backend persistence/revert. That requires the affected customer's policyID.

    Reproduction attempt (web) — basic case persisted

    Setting a first approver on a workflow and saving persisted correctly across navigating to Home and back, and across switching tabs. Multi/additional approvers are gated behind the Control plan upgrade and couldn't be exercised on the Collect-plan test workspace, so the phone/edge-case path was not tested.

    Workflows page immediately after saving the approver change

    Workflows page immediately after saving the approver change

    Workflows page after navigating to Home and back

    Workflows page after navigating to Home and back

    Workflows page after navigating to Members tab and back

    Workflows page after navigating to Members tab and back

    Related issues


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


    view run

  5. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Aug 21, 2026
  6. melvin-bot commented on Aug 21, 2026

    @melvin-bot

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

  7. melvin-bot commented on Aug 21, 2026

    @melvin-bot

    Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

  8. mkhutornyi commented on Aug 21, 2026

    @mkhutornyi
    Contributor

    Not reproduced the exact bug in OP but while testing, I found another related bug.

    Precondition: Employee 1 is approver

    1. Go offline
    2. Admin: remove Employee 1 from members list
    3. Approver is automatically switched to Admin (expected)
    4. Open Edit approval workflow > Approver
    5. Set approver to Employee 2 and Save
    6. While approver in default workflow is replaced with Employee 2, another broken workflow appears witth approver: admin, Expenses from: nothing (bug)
    7. Go online
    8. Broken workflow disappears
    Image
    repro.mov

    @MelvinBot investigate this optimistic bug

  9. MelvinBot commented on Aug 21, 2026

    @MelvinBot
    Contributor

    Proposal

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

    While offline, removing the current approver (Employee 1) from members — which auto-reassigns the default approver to Admin — and then editing the workflow's approver to Employee 2 produces a phantom duplicate workflow ("Approver: admin, Expenses from: nothing") next to the correct one. It disappears on reconnect. Confirmed reproduced (see below).

    What is the root cause of that problem?

    The optimistic member-removal path updates policy.approver but does not reassign the submitters who pointed at the removed member, leaving the workflow derivation in an inconsistent state that synthesizes an empty default workflow.

    In removeMembers (src/libs/actions/Policy/Member.ts:394-420), the optimistic data only:

    • marks the removed member pendingAction: DELETE (it stays in employeeList), and
    • moves policy.approver to the admin/owner via findNextApproverInChain.

    It never updates the submitsTo of employees who submitted to the removed approver. So optimistically: policy.approver = admin, but no employee has submitsTo === admin.

    The Workflows list is re-derived from employeeList by convertPolicyEmployeesToApprovalWorkflows. Because no employee submits to the default approver (admin), the loop never emits an isDefault workflow, so this block injects a synthetic empty one — the phantom row:

    • src/libs/WorkflowUtils.ts:271-278 — if (firstWorkflow && !firstWorkflow.isDefault) { unshift({ members: [], approvers: calculateApprovers(... defaultApprover ...), isDefault: true }) }

    Editing the approver to Employee 2 doesn't fix it: updateApprovalWorkflow only rewrites policy.approver when the edited workflow isDefault, so admin stays the default approver with zero submitters and the phantom persists. Going online fixes it because the backend fully removes Employee 1 and sets submitsTo/approver consistently, so the default approver actually has submitters and no synthetic workflow is injected.

    Confirmed reproduction (offline → online)

    After removing Employee 1 offline — approver auto-switched to Admin (single, correct workflow)

    Default workflow approver auto-switched to Admin after removing Employee 1 offline

    After saving Employee 2 as approver (offline) — phantom duplicate appears

    Duplicate workflow with Approver=admin and empty Expenses from, alongside the correct Employee 2 workflow

    Back online — the phantom disappears

    After going online the duplicate workflow disappears leaving only the correct one

    The a11y tree confirmed the duplicate's "Expenses from" had no value (truly empty), and only one workflow block remained after sync.

    Confidence: high — deterministically reproduced and the optimistic code path is unambiguous.

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

    Primary fix (source of the inconsistency): in removeMembers (src/libs/actions/Policy/Member.ts:394-420), make the optimistic employeeList mirror the backend: for every employee whose submitsTo (and forwardsTo/overLimitForwardsTo) points at a removed member, reassign it to the new default approver (the same value written to policy.approver). Then the default approver actually has submitters and no phantom workflow is derived.

    Optional defensive guard in convertPolicyEmployeesToApprovalWorkflows: don't synthesize the empty default workflow when the default approver has no submitters, and skip emitting workflows keyed on a pendingAction: DELETE approver. This treats the symptom, so prefer the primary fix.

    What alternative solutions did you explore?

    N/A — the primary fix aligns the optimistic state with what the backend already returns, which is why the bug self-heals online.


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


    view run

  10. oqildev commented on Aug 23, 2026

    @oqildev
    Contributor

    @mkhutornyi Melvin's root cause looks off - that unshift block builds an isDefault: true workflow, so it would render first with the default hint, but the broken card in your video is second with no hint.

    The real cause: a member with pendingAction: DELETE isn't pushed into workflow.members, but their old submitsTo still creates the workflow entry, so you end up with a group that has an approver and nobody in it.

    Skipping them before that entry is created fixes it. Tests go from 2 cards to 1.

  11. mallenexpensify commented on Aug 24, 2026

    @mallenexpensify
    Contributor

    @mkhutornyi should we create a new issue for the bug you found and let @FitseTLT take over this one since they're able to reproduce?

  12. 6 remaining items

  13. melvin-bot commented on Aug 27, 2026

    @melvin-bot

    @FitseTLT Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  14. FitseTLT commented on Aug 27, 2026

    @FitseTLT
    Contributor

    Reviewing tomorrow

  15. FitseTLT commented on Aug 28, 2026

    @FitseTLT
    Contributor

    Not reproducible asking in slack

  16. getusha commented on Aug 29, 2026

    @getusha
    Contributor

    Click Save

    @FitseTLT @mallenexpensify maybe the customer is confused by/didn't know the fact they had to click "Save" twice for the configuration to be saved?

    Screen.Recording.2026-08-29.at.2.32.08.in.the.afternoon.mov
  17. melvin-bot commented on Aug 31, 2026

    @melvin-bot

    @FitseTLT Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  18. melvin-bot commented on Sep 2, 2026

    @melvin-bot

    @FitseTLT Eep! 4 days overdue now. Issues have feelings too...

  19. melvin-bot commented on Sep 3, 2026

    @melvin-bot

    @FitseTLT Eep! 4 days overdue now. Issues have feelings too...

  20. melvin-bot commented on Sep 3, 2026

    @melvin-bot

    @FitseTLT Eep! 4 days overdue now. Issues have feelings too...

  21. mallenexpensify commented on Sep 3, 2026

    @mallenexpensify
    Contributor

    Closing per @FitseTLT 's request here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorNeeds ReproductionReproducible steps needed

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions