You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$175] Changes to 'Expenses from' are auto-saved when going back. #107156
Version Number: v9.5.40-0 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack:#106776 Email or phone of affected tester (no customers):vupham12990+18b@gmail.com Issue reported by: Applause Internal Team Bug source: Pull Request QA execution Device used: Google Pixel 8 - Android 16; Windows 10-Chrome App Component: Left Hand Navigation (LHN)
Action Performed:
Precondition: the account has a workspace that invites some members
Open Expensify app
Log in with the account at the preconditions
Tap on the Workspaces tab> Workflows
Tap on the 'Add approval workflow'
Choose one or some member from the 'Expenses from' page, then tap on the Next button
Choose any member from the 'Approver' page
Tap on the 'Add workflow' from the 'Confirm' button
Tap on the workflow that was created at step 7> 'Expense from'
Choose some other members, then tap on the back button
Expected Result:
After step 9, the previously saved members in the 'Expenses from' field remain unchanged.
Actual Result:
After step 9, the selected members appear in the 'Expenses from' field even though the user hasn't tapped the 'Save' button. This contradicts step 2 of PR 106776.
changed the title [-]Android- Changes to 'Expenses from' are auto-saved when going back.[/-][+]Android - Changes to 'Expenses from' are auto-saved when going back.[/+]on Nov 17, 2026
changed the title [-]Android - Changes to 'Expenses from' are auto-saved when going back.[/-][+]Changes to 'Expenses from' are auto-saved when going back.[/+]on Nov 17, 2026
changed the title [-]Changes to 'Expenses from' are auto-saved when going back.[/-][+][$175] Changes to 'Expenses from' are auto-saved when going back.[/+]on Nov 17, 2026
Confidence: Medium — the code explains the reported behavior; runtime reproduction and backend persistence were not verified.
What is the root cause of that problem?
The “Expenses from” picker updates the shared workflow draft immediately when members are selected. Going Back does not restore the previous selection, so the parent editor displays the unsaved changes.
This is draft leakage, not confirmed server-side autosaving. Saving the parent workflow afterward can persist those unintended changes.
Code evidence and alternative explanations checked
The linked MenuItem migration PR is not established as the cause. The picker, parent edit page, and workflow editor are unchanged from its base revision. Its multi-select QA instruction concerns a different setup-field component.
What changes do you think we should make in order to solve the problem?
Give the picker an explicit cancellation boundary:
Capture the member selection when the picker opens.
Restore that selection when leaving without Save.
Keep the changed selection only after Save.
Preserve unrelated workflow edits and existing invitation, creation, and fast-edit behavior.
Use the picker-entry selection, not the workflow’s original persisted members. Otherwise, canceling a later edit could undo an earlier selection explicitly saved into the parent draft. Handle browser Back as well as the header Back button.
Regression coverage
Add tests for:
Selecting and deselecting existing members, then Back: previous members remain.
Save → reopen → change → Back: the last explicitly saved selection remains.
Picker Save updates the parent draft; backend persistence waits for parent Save.
Invitation handoff, creation, and fast-edit cancellation remain unchanged.
Existing save/cleanup tests do not cover ordinary nested-edit cancellation.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/107156) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
Please re-state the problem that we are trying to solve in this issue.
When editing an existing approval workflow, changing the members on the "Expenses from" page and then pressing Back (without Save) still applies the new selection to the workflow.
What is the root cause of that problem?
In src/pages/workspace/workflows/approvals/DynamicWorkspaceWorkflowsApprovalsExpensesFromPage.tsx, every toggle writes straight into the shared workflow draft. toggleMember → applySelection ends with:
So approvalWorkflow.members in Onyx (which ApprovalWorkflowEditor reads for the "Expenses from" field) changes on each tap, before Save.
On Back, goBack only calls dropUnconfirmedStagedMembers(), which filters out people who aren't in policy.employeeList yet. Existing workspace members that were added or removed stay in the draft, and the unmount cleanup only calls clearApprovalWorkflow() for the initial create flow or fast edit. That's why the edit page shows the unsaved selection, and saving the workflow afterward would persist it.
What changes do you think we should make in order to solve the problem?
Give the page a cancel point for the regular edit flow (not initial creation, not fast edit, which already clear the draft):
Add const membersOnEntryRef = useRef<Member[] | undefined>(undefined) and set it once, the first time approvalWorkflow?.members is available on mount.
Add const didSaveRef = useRef(false) and set it to true at the start of nextStep (Save/Next), and when handing off to the invite-message page (the same place isHandingOffToInviteRef.current = true is set).
In goBack, if !didSaveRef.current and we're in the edit flow, call setApprovalWorkflowMembers(membersOnEntryRef.current) and restore the invite draft to its entry value, instead of only dropping unconfirmed invitees.
Do the same restore in the existing unmount cleanup effect, so browser/Android hardware back (which doesn't go through onBackButtonPress) behaves the same.
Using the snapshot from page entry (not the server's members) means that if the user saved a selection, reopened the page and then backed out, they keep the last selection they saved into the parent draft.
What specific scenarios should we cover in automated tests?
In a UI test for DynamicWorkspaceWorkflowsApprovalsExpensesFromPage, with an edit-action approvalWorkflow draft:
Toggle an existing member on/off, press Back → approvalWorkflow.members equals the original list.
Toggle a member, press Save → draft has the new list.
Save, reopen, toggle again, Back → draft keeps the saved list from the first Save.
Initial creation and fast-edit flows still clear the draft on unmount as they do today.
What alternative solutions did you explore?
Keep the selection in local useState and only call setApprovalWorkflowMembers in nextStep. That's cleaner, but selectedMembers currently relies on the Onyx draft so non-policy invitees survive Onyx re-renders (see the comment in applySelection), so it's a larger change with more risk to the invite flow.
Please re-state the problem that we are trying to solve in this issue.
When editing an existing approval workflow (or re-opening Expenses from from the workflow confirm screen), toggling members on DynamicWorkspaceWorkflowsApprovalsExpensesFromPage and pressing Back without tapping Save still keeps the modified member list in ONYXKEYS.APPROVAL_WORKFLOW.members on the parent screen.
What is the root cause of that problem?
In src/pages/workspace/workflows/approvals/DynamicWorkspaceWorkflowsApprovalsExpensesFromPage.tsx, toggleMember -> applySelection writes every selection change straight to Onyx (setWorkspaceInviteMembersDraft and setApprovalWorkflowMembers) before the user confirms with Save / Next:
Meanwhile, goBack only invokes dropUnconfirmedStagedMembers(), which strips non-policy invitees (!policy?.employeeList?.[normalizeLogin(m.email)]) while leaving added/removed workspace members in ONYXKEYS.APPROVAL_WORKFLOW.members, and the unmount cleanup only calls clearApprovalWorkflow() when isInitialCreationFlow || isFastEdit.
What changes do you think we should make in order to solve the problem?
Keep tentative member edits local to the picker until nextStep commits them, and guard the invite-message round-trip against cancellation:
Stage selections in local component state instead of mutating shared Onyx on every tap:
Add draftMembers (useState<Member[] | undefined>) and draftInviteDraft (useState<Record<string, number> | undefined>) in DynamicWorkspaceWorkflowsApprovalsExpensesFromPage.
Use const activeMembers = draftMembers ?? approvalWorkflow?.members; and const activeInviteDraft = draftInviteDraft ?? invitedEmailsToAccountIDsDraft; in usePersonalDetailsByLogins, selectedMembers, and nextStep. That way FastEditSaveTest cases that seed ONYXKEYS.APPROVAL_WORKFLOW.members before pressing Save work identically, and non-policy search selections still survive Onyx re-renders from searchInServer / personalDetails.
Update applySelection to update draftInviteDraft and draftMembers only (removing premature setWorkspaceInviteMembersDraft / setApprovalWorkflowMembers writes on toggle).
Commit to Onyx only inside nextStep:
nextStep already calls setApprovalWorkflowMembers(allMembers) (and setWorkspaceInviteMembersDraft(...) when usersToInvite.length > 0). Only that confirmation path should write back to shared Onyx.
Handle the WORKSPACE_INVITE_MESSAGE back-then-cancel edge case & entry snapshot:
Capture membersOnEntryRef (and inviteDraftOnEntryRef) once when approvalWorkflow?.members is first loaded.
Because nextStep writes allMembers to Onyx before navigating to DYNAMIC_ROUTES.WORKSPACE_INVITE_MESSAGE, track didCommitInviteHandoffRef and reset isHandingOffToInviteRef.current = false when focus returns (useIsFocused transition false -> true).
If the user backs out of the invite-message page back to Expenses from and then presses header Back or browser/hardware Back (unmount cleanup while !isHandingOffToInviteRef.current), restore membersOnEntryRef.current (for non-initial, non-fast-edit flows) and clear/restore the invite draft so canceled invite round-trips never leak earlier toggles either.
What specific scenarios should we cover in automated tests?
Extend tests/ui/ coverage (alongside DynamicWorkspaceWorkflowsApprovalsExpensesFromPageFastEditSaveTest.tsx) to verify:
Opening DynamicWorkspaceWorkflowsApprovalsExpensesFromPage in edit mode (isFastEdit: false), toggling workspace members, and triggering onBackButtonPress or unmount (browser/hardware back) leaves ONYXKEYS.APPROVAL_WORKFLOW.members unchanged.
Toggling members, pressing Save, reopening Expenses from, toggling again, and backing out preserves the members from step 1's Save (not the original persisted server list, and not the canceled toggles).
Selecting a non-member + workspace member, pressing Save (handing off to invite-message), returning focus without inviting, and backing out restores the entry approvalWorkflow.members.
Existing initial creation, fast-edit save, fast-edit discard on unmount, and fast-edit invite handoff tests continue to pass unchanged.
What alternative solutions did you explore?
Always writing to ONYXKEYS.APPROVAL_WORKFLOW.members inside applySelection and rolling back to membersOnEntryRef on goBack/unmount. That leaves two subtle rough edges:
On hardware/browser back, ApprovalWorkflowEditor on the underlying edit page renders during unmount before the async Onyx rollback completes, whereas keeping applySelection in local state means ONYXKEYS.APPROVAL_WORKFLOW.members is never dirtied at all during normal cancel.
Marking a single didSaveRef = true when handing off to WORKSPACE_INVITE_MESSAGE breaks rollback if the user navigates back from the invite screen and then cancels out of Expenses from. Keeping edits local until nextStep and clearing isHandingOffToInviteRef on refocus avoids both issues cleanly.
The Expenses from picker writes tentative selections into the shared approval-workflow draft before the user confirms them.
In DynamicWorkspaceWorkflowsApprovalsExpensesFromPage.tsx, applySelection calls setApprovalWorkflowMembers and updates the invitation draft during selection. setApprovalWorkflowMembers merges members into Onyx; this is not itself a backend save.
The Back path removes unconfirmed non-workspace invitees but does not restore changes involving existing workspace members. Since ApprovalWorkflowEditor reads that same shared draft, canceled selections remain visible in the parent editor.
What changes do you think we should make in order to solve the problem?
Keep tentative member selection local to the picker, initialized from the entry draft. Do not update shared workflow members on each toggle.
Apply the selection through the existing explicit Save/Next contract, preserving creation, normal editing and fast-edit behavior. Do not save the parent workflow prematurely.
Handle the invitation handoff explicitly: abandoning the flow must discard only changes staged by this picker, without deleting previously confirmed members or invitations.
Extend the existing picker UI tests to cover:
Selecting or removing existing members, then returning without Save.
Header Back and route removal.
Save, reopen, change and cancel.
Invitation handoff, return and cancellation.
Existing creation and fast-edit behavior.
The draft mutation is confirmed in source; backend autosaving and the complete reported flow have not been independently reproduced.
What alternative solutions did you explore? (Optional)
An entry snapshot with rollback is smaller, but exposes intermediate shared-state changes and requires careful navigation cleanup. A local tentative selection provides a clearer confirmation boundary. Clearing the entire workflow draft would risk losing valid parent-editor changes.
Please re-state the problem that we are trying to solve in this issue.
In the Workflows approval editor, opening "Expenses from" for an existing workflow, picking different members, and then tapping Back changes the members shown in the editor even though Save was never tapped. The previously saved members should remain unchanged until the admin explicitly saves.
What is the root cause of that problem?
This is draft leakage in the picker, not a server-side autosave. Every consumer reads and writes one shared Onyx draft, APPROVAL_WORKFLOW, and the picker writes into it on every toggle:
toggleMember in DynamicWorkspaceWorkflowsApprovalsExpensesFromPage.tsx calls applySelection on every tap, and applySelection calls setApprovalWorkflowMembers(workflowMembers) immediately. setApprovalWorkflowMembers (src/libs/actions/Workflow.ts) is just Onyx.merge(ONYXKEYS.APPROVAL_WORKFLOW, {members, errors: null}), so the new selection lands in the shared draft before any Save.
goBack only calls dropUnconfirmedStagedMembers, which removes non-policy members that were staged for invite but never confirmed. It does not undo the member change itself.
The parent editor (ApprovalWorkflowEditor.tsx) renders its member pills straight from approvalWorkflow.members in the same draft, so it shows the changed members the moment the admin returns. A later Save on the parent would then persist the unintended change with updateApprovalWorkflow / updateApprovalWorkflowRules, using the edit page's own snapshot as the diff baseline.
So in the plain edit flow, Save (nextStep) and Back (goBack) are indistinguishable for members: both end with the draft holding the new selection. The same leak exists on the create Confirm page, which reads the same draft.
I checked the two alternative explanations and ruled them out: the MenuItem migration in PR #106776 did not touch this picker, the parent edit page, or the workflow editor, and its multi-select QA step concerns a different setup-field component; and nothing in this flow makes an API request on toggle, so no server-side autosave is involved.
What changes do you think we should make in order to solve the problem?
Give the picker an explicit cancellation boundary: capture the member selection when the picker opens, and restore it when leaving without Save. Keep the changed selection only after Save.
src/pages/workspace/workflows/approvals/DynamicWorkspaceWorkflowsApprovalsExpensesFromPage.tsx (+55 lines, no other file changed):
Capture the entry selection once in entryMembersRef, the first time the draft has members. The anchor is the picker-entry selection, not originalMembers: a selection the parent already saved in an earlier round must survive a later cancel. Restoring originalMembers would undo that earlier save, since the edit page does not re-seed originalMembers when it resumes after a sub-page round-trip.
Restore the entry selection in goBack (header back button), and again in the unmount cleanup, which covers browser back and swipe back, both of which leave the page without calling goBack.
Skip the restore when the new selection is intentional: nextStep sets a didSaveRef flag, which covers Save in the edit flow, Next in the create flow, and the invite hand-off. The initial create step and the fast edit keep their existing behavior of discarding the whole draft on unmount.
Preserve the existing rule that an unconfirmed invitee never survives a back navigation: the restore filters the entry selection to policy members plus members still in the invite draft, using the latest values (kept in refs for the cleanup, which only sees the first render's closure).
Tests. New tests/ui/DynamicWorkspaceWorkflowsApprovalsExpensesFromPageBackCancelTest.tsx, 5 tests, all passing (4 fail on baseline, 5 pass with the fix):
Change members then press Back: the draft returns to the entry members.
Change members then leave without a Back press (browser back): the draft returns to the entry members.
Change members then press Save: the new members stay in the draft for the parent to save.
Save, reopen, change, Back: the last saved selection remains, not the original members.
An unconfirmed staged member in the entry selection is dropped when backing out.
Related suites still green: DynamicWorkspaceWorkflowsApprovalsExpensesFromPageTest, DynamicWorkspaceWorkflowsApprovalsExpensesFromPageFastEditSaveTest, and WorkspaceWorkflowsApprovalsEditPageTest (22 tests total).
What alternative solutions did you explore? (Optional)
Restore originalMembers on Back. Rejected: originalMembers is seeded once when the edit page first mounts and is not refreshed when the parent saves. Canceling a later edit would undo a selection the parent already saved.
Keep the selection in local state and write the draft only on Save. A bigger refactor: the selection list, the invite-draft sync, and both cross-workflow warnings all derive from the draft today. The snapshot-restore keeps the same behavior with a much smaller change.
Fix it in the parent edit page instead. Rejected: the leak is created in the picker, and the parent cannot tell a saved selection from a leaked one, since both live in the same draft. The picker is also the only place that knows when the session started.
Restore only in goBack, not in the unmount cleanup. Rejected: browser back and swipe back leave the page without calling goBack, so the leak would remain on those paths.
Verification notes. The fix is verified by the UI tests above, which render the real page against Onyx and drive the selection the way the list does. A real-device run of the Applause steps (create a workflow, reopen "Expense from", pick other members, tap Back, confirm the saved members are unchanged) is still worth doing before merge, since the tests run under jsdom. Lint and full typecheck could not be run to green on the prep VM: lint-changed timed out fetching origin/main and direct oxlint fails on the known environment breakage (the hosted-rules plugin cannot load through the symlinked node_modules); the full typecheck was OOM-killed three times, which is a machine limit, not a type error report. The targeted checks that could run are clean: cspell reports 0 issues on both changed files, esbuild parses both files, and the invite-draft value passed to the new helper is typed Record<string, number> | undefined, matching the helper's parameter, since OnyxEntry<T> is T | undefined in this codebase. Lint and typecheck should be re-run on a machine with enough memory before the PR is opened.
Activity
applause-bot commentedon Nov 17, 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/29a0bec78616db7d5da4f2e04a13db0224a95ac5625e483658ddb783f721c5a5
[-]Android- Changes to 'Expenses from' are auto-saved when going back.[/-][+]Android - Changes to 'Expenses from' are auto-saved when going back.[/+][-]Android - Changes to 'Expenses from' are auto-saved when going back.[/-][+]Changes to 'Expenses from' are auto-saved when going back.[/+]expensify-chore-bot commentedon Nov 17, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @hoangzinh (
External)[-]Changes to 'Expenses from' are auto-saved when going back.[/-][+][$175] Changes to 'Expenses from' are auto-saved when going back.[/+]expensify-chore-bot commentedon Nov 17, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022122775088592578757
MelvinBot commentedon Nov 17, 2026
Proposal
Confidence: Medium — the code explains the reported behavior; runtime reproduction and backend persistence were not verified.
What is the root cause of that problem?
The “Expenses from” picker updates the shared workflow draft immediately when members are selected. Going Back does not restore the previous selection, so the parent editor displays the unsaved changes.
This is draft leakage, not confirmed server-side autosaving. Saving the parent workflow afterward can persist those unintended changes.
Code evidence and alternative explanations checked
setApprovalWorkflowMembers: DynamicWorkspaceWorkflowsApprovalsExpensesFromPage.tsx:476–504.The linked MenuItem migration PR is not established as the cause. The picker, parent edit page, and workflow editor are unchanged from its base revision. Its multi-select QA instruction concerns a different setup-field component.
What changes do you think we should make in order to solve the problem?
Give the picker an explicit cancellation boundary:
Use the picker-entry selection, not the workflow’s original persisted members. Otherwise, canceling a later edit could undo an earlier selection explicitly saved into the parent draft. Handle browser Back as well as the header Back button.
Regression coverage
Add tests for:
Existing save/cleanup tests do not cover ordinary nested-edit cancellation.
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/107156)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
view run
fitzyracing1 commentedon Nov 17, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When editing an existing approval workflow, changing the members on the "Expenses from" page and then pressing Back (without Save) still applies the new selection to the workflow.
What is the root cause of that problem?
In
src/pages/workspace/workflows/approvals/DynamicWorkspaceWorkflowsApprovalsExpensesFromPage.tsx, every toggle writes straight into the shared workflow draft.toggleMember→applySelectionends with:So
approvalWorkflow.membersin Onyx (whichApprovalWorkflowEditorreads for the "Expenses from" field) changes on each tap, before Save.On Back,
goBackonly callsdropUnconfirmedStagedMembers(), which filters out people who aren't inpolicy.employeeListyet. Existing workspace members that were added or removed stay in the draft, and the unmount cleanup only callsclearApprovalWorkflow()for the initial create flow or fast edit. That's why the edit page shows the unsaved selection, and saving the workflow afterward would persist it.What changes do you think we should make in order to solve the problem?
Give the page a cancel point for the regular edit flow (not initial creation, not fast edit, which already clear the draft):
const membersOnEntryRef = useRef<Member[] | undefined>(undefined)and set it once, the first timeapprovalWorkflow?.membersis available on mount.const didSaveRef = useRef(false)and set it totrueat the start ofnextStep(Save/Next), and when handing off to the invite-message page (the same placeisHandingOffToInviteRef.current = trueis set).goBack, if!didSaveRef.currentand we're in the edit flow, callsetApprovalWorkflowMembers(membersOnEntryRef.current)and restore the invite draft to its entry value, instead of only dropping unconfirmed invitees.onBackButtonPress) behaves the same.Using the snapshot from page entry (not the server's members) means that if the user saved a selection, reopened the page and then backed out, they keep the last selection they saved into the parent draft.
What specific scenarios should we cover in automated tests?
In a UI test for
DynamicWorkspaceWorkflowsApprovalsExpensesFromPage, with an edit-actionapprovalWorkflowdraft:approvalWorkflow.membersequals the original list.What alternative solutions did you explore?
Keep the selection in local
useStateand only callsetApprovalWorkflowMembersinnextStep. That's cleaner, butselectedMemberscurrently relies on the Onyx draft so non-policy invitees survive Onyx re-renders (see the comment inapplySelection), so it's a larger change with more risk to the invite flow.cocvn157 commentedon Nov 18, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When editing an existing approval workflow (or re-opening Expenses from from the workflow confirm screen), toggling members on
DynamicWorkspaceWorkflowsApprovalsExpensesFromPageand pressing Back without tapping Save still keeps the modified member list inONYXKEYS.APPROVAL_WORKFLOW.memberson the parent screen.What is the root cause of that problem?
In
src/pages/workspace/workflows/approvals/DynamicWorkspaceWorkflowsApprovalsExpensesFromPage.tsx,toggleMember->applySelectionwrites every selection change straight to Onyx (setWorkspaceInviteMembersDraftandsetApprovalWorkflowMembers) before the user confirms with Save / Next:https://github.com/Expensify/App/blob/main/src/pages/workspace/workflows/approvals/DynamicWorkspaceWorkflowsApprovalsExpensesFromPage.tsx#L502-L503
Meanwhile,
goBackonly invokesdropUnconfirmedStagedMembers(), which strips non-policy invitees (!policy?.employeeList?.[normalizeLogin(m.email)]) while leaving added/removed workspace members inONYXKEYS.APPROVAL_WORKFLOW.members, and the unmount cleanup only callsclearApprovalWorkflow()whenisInitialCreationFlow || isFastEdit.What changes do you think we should make in order to solve the problem?
Keep tentative member edits local to the picker until
nextStepcommits them, and guard the invite-message round-trip against cancellation:draftMembers(useState<Member[] | undefined>) anddraftInviteDraft(useState<Record<string, number> | undefined>) inDynamicWorkspaceWorkflowsApprovalsExpensesFromPage.const activeMembers = draftMembers ?? approvalWorkflow?.members;andconst activeInviteDraft = draftInviteDraft ?? invitedEmailsToAccountIDsDraft;inusePersonalDetailsByLogins,selectedMembers, andnextStep. That wayFastEditSaveTestcases that seedONYXKEYS.APPROVAL_WORKFLOW.membersbefore pressing Save work identically, and non-policy search selections still survive Onyx re-renders fromsearchInServer/personalDetails.applySelectionto updatedraftInviteDraftanddraftMembersonly (removing prematuresetWorkspaceInviteMembersDraft/setApprovalWorkflowMemberswrites on toggle).nextStep:nextStepalready callssetApprovalWorkflowMembers(allMembers)(andsetWorkspaceInviteMembersDraft(...)whenusersToInvite.length > 0). Only that confirmation path should write back to shared Onyx.WORKSPACE_INVITE_MESSAGEback-then-cancel edge case & entry snapshot:membersOnEntryRef(andinviteDraftOnEntryRef) once whenapprovalWorkflow?.membersis first loaded.nextStepwritesallMembersto Onyx before navigating toDYNAMIC_ROUTES.WORKSPACE_INVITE_MESSAGE, trackdidCommitInviteHandoffRefand resetisHandingOffToInviteRef.current = falsewhen focus returns (useIsFocusedtransitionfalse -> true).!isHandingOffToInviteRef.current), restoremembersOnEntryRef.current(for non-initial, non-fast-edit flows) and clear/restore the invite draft so canceled invite round-trips never leak earlier toggles either.What specific scenarios should we cover in automated tests?
Extend
tests/ui/coverage (alongsideDynamicWorkspaceWorkflowsApprovalsExpensesFromPageFastEditSaveTest.tsx) to verify:DynamicWorkspaceWorkflowsApprovalsExpensesFromPagein edit mode (isFastEdit: false), toggling workspace members, and triggeringonBackButtonPressorunmount(browser/hardware back) leavesONYXKEYS.APPROVAL_WORKFLOW.membersunchanged.approvalWorkflow.members.What alternative solutions did you explore?
Always writing to
ONYXKEYS.APPROVAL_WORKFLOW.membersinsideapplySelectionand rolling back tomembersOnEntryRefongoBack/unmount. That leaves two subtle rough edges:ApprovalWorkflowEditoron the underlying edit page renders during unmount before the async Onyx rollback completes, whereas keepingapplySelectionin local state meansONYXKEYS.APPROVAL_WORKFLOW.membersis never dirtied at all during normal cancel.didSaveRef = truewhen handing off toWORKSPACE_INVITE_MESSAGEbreaks rollback if the user navigates back from the invite screen and then cancels out of Expenses from. Keeping edits local untilnextStepand clearingisHandingOffToInviteRefon refocus avoids both issues cleanly.Vallejo1921 commentedon Nov 18, 2026
Proposal
What is the root cause of that problem?
The Expenses from picker writes tentative selections into the shared approval-workflow draft before the user confirms them.
In
DynamicWorkspaceWorkflowsApprovalsExpensesFromPage.tsx,applySelectioncallssetApprovalWorkflowMembersand updates the invitation draft during selection.setApprovalWorkflowMembersmerges members into Onyx; this is not itself a backend save.The Back path removes unconfirmed non-workspace invitees but does not restore changes involving existing workspace members. Since
ApprovalWorkflowEditorreads that same shared draft, canceled selections remain visible in the parent editor.What changes do you think we should make in order to solve the problem?
Keep tentative member selection local to the picker, initialized from the entry draft. Do not update shared workflow members on each toggle.
Apply the selection through the existing explicit Save/Next contract, preserving creation, normal editing and fast-edit behavior. Do not save the parent workflow prematurely.
Handle the invitation handoff explicitly: abandoning the flow must discard only changes staged by this picker, without deleting previously confirmed members or invitations.
Extend the existing picker UI tests to cover:
The draft mutation is confirmed in source; backend autosaving and the complete reported flow have not been independently reproduced.
What alternative solutions did you explore? (Optional)
An entry snapshot with rollback is smaller, but exposes intermediate shared-state changes and requires careful navigation cleanup. A local tentative selection provides a clearer confirmation boundary. Clearing the entire workflow draft would risk losing valid parent-editor changes.
expensify-chore-bot commentedon Nov 20, 2026
@hoangzinh Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
dankezo commentedon Nov 21, 2026
Contributor details
Your Expensify account email: dannyphan190@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~013b564a690d9bcdab
Proposal
Please re-state the problem that we are trying to solve in this issue.
In the Workflows approval editor, opening "Expenses from" for an existing workflow, picking different members, and then tapping Back changes the members shown in the editor even though Save was never tapped. The previously saved members should remain unchanged until the admin explicitly saves.
What is the root cause of that problem?
This is draft leakage in the picker, not a server-side autosave. Every consumer reads and writes one shared Onyx draft,
APPROVAL_WORKFLOW, and the picker writes into it on every toggle:toggleMemberinDynamicWorkspaceWorkflowsApprovalsExpensesFromPage.tsxcallsapplySelectionon every tap, andapplySelectioncallssetApprovalWorkflowMembers(workflowMembers)immediately.setApprovalWorkflowMembers(src/libs/actions/Workflow.ts) is justOnyx.merge(ONYXKEYS.APPROVAL_WORKFLOW, {members, errors: null}), so the new selection lands in the shared draft before any Save.goBackonly callsdropUnconfirmedStagedMembers, which removes non-policy members that were staged for invite but never confirmed. It does not undo the member change itself.ApprovalWorkflowEditor.tsx) renders its member pills straight fromapprovalWorkflow.membersin the same draft, so it shows the changed members the moment the admin returns. A later Save on the parent would then persist the unintended change withupdateApprovalWorkflow/updateApprovalWorkflowRules, using the edit page's own snapshot as the diff baseline.So in the plain edit flow, Save (
nextStep) and Back (goBack) are indistinguishable for members: both end with the draft holding the new selection. The same leak exists on the create Confirm page, which reads the same draft.I checked the two alternative explanations and ruled them out: the MenuItem migration in PR #106776 did not touch this picker, the parent edit page, or the workflow editor, and its multi-select QA step concerns a different setup-field component; and nothing in this flow makes an API request on toggle, so no server-side autosave is involved.
What changes do you think we should make in order to solve the problem?
Give the picker an explicit cancellation boundary: capture the member selection when the picker opens, and restore it when leaving without Save. Keep the changed selection only after Save.
src/pages/workspace/workflows/approvals/DynamicWorkspaceWorkflowsApprovalsExpensesFromPage.tsx(+55 lines, no other file changed):entryMembersRef, the first time the draft has members. The anchor is the picker-entry selection, notoriginalMembers: a selection the parent already saved in an earlier round must survive a later cancel. RestoringoriginalMemberswould undo that earlier save, since the edit page does not re-seedoriginalMemberswhen it resumes after a sub-page round-trip.goBack(header back button), and again in the unmount cleanup, which covers browser back and swipe back, both of which leave the page without callinggoBack.nextStepsets adidSaveRefflag, which covers Save in the edit flow, Next in the create flow, and the invite hand-off. The initial create step and the fast edit keep their existing behavior of discarding the whole draft on unmount.Tests. New
tests/ui/DynamicWorkspaceWorkflowsApprovalsExpensesFromPageBackCancelTest.tsx, 5 tests, all passing (4 fail on baseline, 5 pass with the fix):Related suites still green:
DynamicWorkspaceWorkflowsApprovalsExpensesFromPageTest,DynamicWorkspaceWorkflowsApprovalsExpensesFromPageFastEditSaveTest, andWorkspaceWorkflowsApprovalsEditPageTest(22 tests total).What alternative solutions did you explore? (Optional)
originalMemberson Back. Rejected:originalMembersis seeded once when the edit page first mounts and is not refreshed when the parent saves. Canceling a later edit would undo a selection the parent already saved.goBack, not in the unmount cleanup. Rejected: browser back and swipe back leave the page without callinggoBack, so the leak would remain on those paths.Verification notes. The fix is verified by the UI tests above, which render the real page against Onyx and drive the selection the way the list does. A real-device run of the Applause steps (create a workflow, reopen "Expense from", pick other members, tap Back, confirm the saved members are unchanged) is still worth doing before merge, since the tests run under jsdom. Lint and full typecheck could not be run to green on the prep VM:
lint-changedtimed out fetchingorigin/mainand direct oxlint fails on the known environment breakage (the hosted-rules plugin cannot load through the symlinked node_modules); the full typecheck was OOM-killed three times, which is a machine limit, not a type error report. The targeted checks that could run are clean: cspell reports 0 issues on both changed files, esbuild parses both files, and the invite-draft value passed to the new helper is typedRecord<string, number> | undefined, matching the helper's parameter, sinceOnyxEntry<T>isT | undefinedin this codebase. Lint and typecheck should be re-run on a machine with enough memory before the PR is opened.melvin-bot commentedon Nov 21, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!