Repository navigation
Description
Coming from here
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?:
Reproducible in production?:
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:
Slack conversation (hyperlinked to channel name):
Action Performed:
Precondition: Employee 1 is approver
- Go offline
- Admin: remove Employee 1 from members list
- Approver is automatically switched to Admin (expected)
- Open Edit approval workflow > Approver
- Set approver to Employee 2 and Save
- While approver in default workflow is replaced with Employee 2, another broken workflow appears witth approver: admin, Expenses from: nothing (bug)
- Go online
- Broken workflow disappears
repro.mov
Expected Result:
Describe what you think should've happened
Actual Result:
Describe what actually happened
Workaround:
Can the user still use Expensify without this being fixed? Have you informed them of the workaround?
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
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022104973675115874311
- Upwork Job ID: 2104973675115874311
- Last Price Increase: 2026-09-29
Activity
mallenexpensify commentedon Aug 24, 2026
@mkhutornyi if anything needs updating in the OP or title, please ping tag me here and ping me in Slack. Thx
MelvinBot commentedon Aug 24, 2026
Proposal
What is the root cause of that problem?
A soft-deleted approver whose stale
submitsTostill points at the Admin creates an empty "phantom" approval workflow that only exists offline.When Employee 1 (the approver) is removed offline, the app auto-reassigns the default workflow's approver to the Admin — which stamps
Employee1.submitsTo = Admin— and then marks Employee 1 withpendingAction: DELETE(Policy/Member.tsMERGEs the DELETE flag while keeping the stalesubmitsTo). When you then edit the default workflow's approver to Employee 2, only live members get theirsubmitsTorewritten to Employee 2 — the deleted Employee 1 is left pointing at Admin.The Workflows list is built by
convertPolicyEmployeesToApprovalWorkflows. It creates a workflow "bucket" for any employee whosesubmitsToresolves to an approver — including the DELETE'd Employee 1 — atWorkflowUtils.ts:198. But members are only pushed into the bucket whenpendingAction !== DELETE(WorkflowUtils.ts:246), so the bucket stays withmembers: []. Since the default approver is now Employee 2, this Admin bucket isn't flaggedisDefault, and there's no filter dropping empty non-default workflows — so it renders as a second, broken row: Approver: Admin, Expenses from: (empty).Online it disappears because the backend removes the deleted employee's entry entirely, so nothing points at Admin and the bucket is never created.
Why it vanishes online + data flow
updateWorkflowDataOnApproverRemovalreassigns default approver to owner/Admin →Employee1.submitsTo = Admin,policy.approver = Admin.removeMembersMERGEs{pendingAction: DELETE}onto Employee 1, preservingsubmitsTo = Admin.submitsTorewritten to Employee 2;policy.approver = Employee 2. Employee 1 (DELETE) still hassubmitsTo = Admin.approvalWorkflows[Admin]but its member is never pushed →members: [],isDefault: false→ renders as an extra broken row.null; no employee points at Admin → bucket never created → row disappears.This is a purely frontend (Expensify/App) optimistic-data bug — the backend returns correct data online.
What changes do you think we should make in order to solve the problem?
In
convertPolicyEmployeesToApprovalWorkflows, skip pending-DELETEemployees before they can create a workflow bucket. Right after theavailableMembershandling (~line 189, thependingActionis already destructured at line 175),continuewhenpendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE.A deleted employee already contributes no member (guard at line 246) and no pendingAction (guard at line 252), so skipping it entirely only removes the phantom bucket and changes nothing else. A live member submitting to the same approver still creates the real bucket normally.
What alternative solutions did you explore? (Optional)
Filter out empty non-default workflows before returning at
WorkflowUtils.ts:270-286:sortedApprovalWorkflows.filter((w) => w.isDefault || w.members.length > 0). This is a safety net but treats the symptom; the primary fix addresses the root cause and avoids risking the intentionally-empty default workflow.Confidence: High — root cause verified against current
maincode with a complete offline→online data flow; no production logs needed since the defect is deterministic in the offline conversion path.Possibly related issues
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/99357)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
view run
melvin-bot commentedon Aug 24, 2026
Current assignee @mkhutornyi is eligible for the External assigner, not assigning anyone new.
melvin-bot commentedon Aug 24, 2026
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.
Abdukhamid000 commentedon Aug 25, 2026
Checked Melvin's analysis against
mainand it holds up.updateApprovalWorkflowdoes optimistically movepolicy.approverto Employee 2 (Workflow.ts:174), so the leftover Admin bucket really is a non-default workflow withmembers: [], and the deleted employee'ssubmitsTois never rewritten because the rewrite loop iteratesapprovalWorkflow.members(WorkflowUtils.ts:398), which excludes it. Two notes for whoever implements.Skipping the pending-DELETE employee is the better option, for a reason beyond "treats the symptom". The rejected alternative — filtering empty non-default workflows at the end — still lets the phantom bucket run
WorkflowUtils.ts:227-231and add Admin tousedApproverEmails, so Admin stays flagged as a used approver in the picker off a workflow that no longer renders. Skipping earlier fixes that too.One gap in the skip itself. If no live employee has a resolvable
submitsTo, skipping every DELETE employee leavesapprovalWorkflowsempty — and the block that guarantees a default workflow only runs when the list is non-empty:App/src/libs/WorkflowUtils.ts
Lines 270 to 278 in 1d0d7de
The page would then render no workflows at all rather than one phantom row. Test fixtures give every employee a
submitsTo, so this is an edge case rather than the common path, but extending that guard to cover the empty list is a one-liner worth doing in the same change.For context, this is the same defect class as the backstop already sitting in
Workflow.ts:121-143— a stalesubmitsToproducing an orphan submission group — just for a pending-DELETE employee instead of a newly-promoted approver.melvin-bot commentedon Aug 27, 2026
@mkhutornyi Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
melvin-bot commentedon Aug 31, 2026
@mkhutornyi Still overdue 6 days?! Let's take care of this!
mkhutornyi commentedon Sep 1, 2026
@MelvinBot draft PR for testing
MelvinBot commentedon Sep 1, 2026
🤖 Draft PR created: #99988
Please mark it as "Ready for review" when it is ready.
What it changes:
WorkflowUtils.tsnow skips employees withpendingAction: DELETEat the top of the conversion loop, so a member removed offline — who keeps a stalesubmitsTountil the backend confirms — can no longer create a workflow they will never be a member of. It also stops that stale approver from landing inusedApproverEmails, whichAbdukhamid000flagged. The same fix is applied toconvertApprovalWorkflowRulesToWorkflows, theMULTIPLE_APPROVERSbeta counterpart, which had the identical defect. Two unit tests cover both paths.I did not take the second half of
Abdukhamid000's suggestion — extending the "guarantee a default workflow" guard to cover an empty list. That guard's current behavior is pinned by two existing tests (Should return an empty list if there are no employeesandShould not include users that submit to non-employee user), so making it unconditional would change behavior beyond this bug. After this fix, a workspace where no live employee has a resolvablesubmitsTorenders no workflows — the same as a workspace where nobody submits to anyone today.AI tests run locally on the branch:
WorkflowUtilsTest(100 passed),WorkflowTest+ApprovalWorkflowSectionTest(21 passed), ESLint on the changed files, andnpm run typecheck— all passed.Manual verification: blocked
So the offline repro from the OP is not confirmed end to end — the unit tests are the only evidence so far. The PR body has the manual steps to run.
Evidence (1)
Blank white page after sign-in, 0 accessibility nodes
view run
26 remaining items
mkhutornyi commentedon Oct 16, 2026
Contributor+ Checklist:
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to the comment on the PR:
Link to the comment on the Issue:
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion:
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Regression Test Proposal
Precondition:
a workspace with an Admin, Employee 1 set as the default approver, and Employee 2
Test:
Do we agree 👍 or 👎
melvin-bot commentedon Oct 21, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Oct 21, 2026
Payment Summary
Resolving PRs:
Skip members pending deletion when building approval workflows #99988
Reviewer: @mkhutornyi owed $175 via NewDot
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Oct 26, 2026
Payment Summary
Contributor+: @mkhutornyi due $250 via NewDot
trjExpensify commentedon Nov 6, 2026
approved $250 for @mkhutornyi