Repository navigation
Description
If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
Version Number: 9.4.67 / 9.4.68 / 9.4.69
Reproducible in staging?: Needs to be confirmed
Reproducible in production?: Yes — crash is live in production
If this was caught during regression testing, add the test name, ID and link from BrowserStack: N/A — found via Sentry production crash scan
Email or phone of affected tester (no customers): N/A
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: Applause / Sentry production crash scan
Slack conversation (hyperlinked to channel name): N/A
Action Performed:
- Open a workspace where the approval workflow has exactly one approver.
- Go to Workspace > Members and open the member details page for that approver.
- Tap Remove from workspace.
- Confirm the removal.
Expected Result:
The member is removed and the workspace falls back to a valid approval workflow (for example, the workspace owner becomes the approver). No crash.
Actual Result:
The app throws an unhandled error and the page crashes.
removeUser() in WorkspaceMemberDetailsPage calls updateApprovalWorkflow(workflow, [], [], policy). convertApprovalWorkflowToPolicyEmployees then reads approvalWorkflow.approvers.at(0), finds it empty, and throws.
Workaround:
Unknown. Reloading the page recovers the session, but the removal does not complete.
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
Sentry details
Sentry issue: https://expensify.sentry.io/issues/APP-9JM
Impact (snapshot at filing, 2026-09-03):
- Users (total since first seen): 3
- Events (total): 16
- Users in scanned releases (9.4.67–9.4.69): 1
- First seen: 2026-04-08
- Last seen: ongoing
- Platform: web
- Affected route (parameterized):
/workspaces/:policyID/members/:accountID - Mechanism:
auto.browser.global_handlers.onunhandledrejection
Stack trace (first-party frames):
src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx:271 removeUser()
src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx:251 updateApprovalWorkflow(workflow, [], [], policy)
src/libs/actions/Workflow.ts:128 convertApprovalWorkflowToPolicyEmployees({...})
src/libs/WorkflowUtils.ts:376 throw new Error('Approval workflow must have at least one approver')
Suspected cause: removing the last remaining approver leaves approvalWorkflow.approvers empty, and convertApprovalWorkflowToPolicyEmployees throws instead of falling back to the default approver.
Related: #57298 covered the same throw and was closed in April 2025. Sentry first saw the current group on 2026-04-08, so this is a regression or a second path into the same throw.
Issue Owner
Current Issue Owner: @mallenexpensifyMetadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
melvin-bot commentedon Sep 3, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @cretadn22 (
External)melvin-bot commentedon Sep 3, 2026
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.
MelvinBot commentedon Sep 3, 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
cretadn22 commentedon Sep 3, 2026
@MelvinBot Investigate this issue
MelvinBot commentedon Sep 3, 2026
Proposal
What is the root cause of that problem?
The synthesized default approval workflow is allowed to be created with zero approvers.
WorkflowUtils.ts:283-292prepends a default workflow whenever no employee submits to the default approver. It callscalculateApprovers, which returns[]immediately ifemployees[defaultApprover]doesn't exist (:78-81). Unlike the in-loop path — which has an explicit empty fallback at:213-224— thisunshifthas no guard.That empty workflow then flows straight through:
updateWorkflowDataOnApproverRemovalseesapprovers.length === 0, soisSingleApproverandisMultipleApproversare both false and every.some(...)on[]is false. It falls to the pass-throughreturn workflowat:557— unchanged, and not flaggedremoveApprovalWorkflow.removeUser()loops over every returned workflow and callsupdateApprovalWorkflowon it — including this untouched, unrelated, empty one.WorkflowUtils.ts:376.Repro conditions (all four required — which is why this is only 3 users / 16 events, and why the steps in the issue body won't reproduce it):
firstWorkflow.isDefault === falseand theunshiftruns.defaultApprover—getHRFinalApprover(policy) ?? getDefaultApprover(policy)(:175) — is not a key inemployeeList. Real sources: a stalepolicy.approverpointing at an already-removed member, an HR/GustofinalApproverwho isn't a workspace member, or the secondary/primary login mismatch noted atMember.ts:388-408.isPolicyApprover, soremoveUsertakes the workflow branch at all.This is not a regression from one PR. The unguarded
unshifthas been there since Aug 2024; the fix for #57298 (PR #59468, Apr 2025) only added!employees[submitsTo]to the in-loop skip — which is exactly what makes condition 2 true more often. So this is a second path into the same throw, not the old bug returning.What changes do you think we should make in order to solve the problem?
Fix the producer — make the synthesized default workflow unable to have zero approvers. In
WorkflowUtils.ts:283-292, mirror the existing in-loop fallback at:213-224: ifcalculateApproverscomes back empty, build a single approver fromdefaultApprover(falling back topolicy.owner), and if there's no usable email at all, skip theunshiftentirely. Extract this into one shared helper, because the identical unguarded block is copy-pasted into the beta converter at:1705-1712and needs the same treatment.This also fixes two side effects of the same bad data: the
defaultHasOwnercheck at:470silently evaluating false, and an empty default-workflow card rendering on the workflows page.Add defense in depth — at the top of the
flatMapcallback inupdateWorkflowDataOnApproverRemoval(:465), drop any workflow with no approvers by returning[]. Because it's aflatMap, that removes the workflow and both call sites are fixed with no change at either (WorkspaceMemberDetailsPage.tsx:245andWorkspaceMembersPage.tsx:249). Note: flagging itremoveApprovalWorkflow: trueinstead would not work —removeApprovalWorkflowcalls the same converter and would throw again.Tests to add (all three cases are currently uncovered — see details):
convertPolicyEmployeesToApprovalWorkflowswithpolicy.approverabsent fromemployeeListplus one real workflow → the default workflow must have at least one approver.finalApprovernot inemployeeList.updateWorkflowDataOnApproverRemovalgiven a workflow withapprovers: []→ must not emit it.What alternative solutions did you explore? (Optional)
removeUser()only — rejected. It would have to be duplicated inWorkspaceMembersPage.tsx, and the corrupt workflow would still render in the approvals UI.:376to a graceful return — rejected. It's a real invariant guarding three writers (createApprovalWorkflow,updateApprovalWorkflow,removeApprovalWorkflow). Returning{}would silently no-op user-initiated create/edit saves fromWorkspaceWorkflowsApprovalsEditPage.tsxand hide future data bugs.Supporting evidence
Why
updateWorkflowDataOnApproverRemovalis not the culprit. Every branch that returns a modifiedapproversarray is provably non-empty: owner substitution yields 1; thehasOverLimitToRemovedApprover.map()preserves length;removedIndex === 0on a multi-approver chain does.slice(1)on a length ≥2 array; theslice(0, idx)branches are guaranteedidx > 0becauseidx === 0is handled earlier; and[...slice(0, idx), owner]yields ≥2. The only exits carrying an empty array are the two unmodified pass-throughs at:557and:659.A second, narrower producer of
approvers: []. The Expensify-team filter at:225-227runs after the in-loop empty fallback, so it can re-empty the array when the entire chain is@expensify.com— plausible on customer workspaces where a member submits to a Guide. This landed after Sentry first saw the group (2026-04-08), so it isn't the original trigger, but the recommended producer-side fix should account for it.Existing test coverage gaps. In
tests/unit/WorkflowUtilsTest.ts,updateWorkflowDataOnApproverRemovalhas 12 cases and every input workflow has at least one approver.convertApprovalWorkflowToPolicyEmployeeshas 8 cases and none asserts the throw. TheconvertPolicyEmployeesToApprovalWorkflowssuite includes the #59468 regression test, but itsdefaultApproveris an employee, so the result is[]and theunshiftnever runs; itscreateMockPolicyhelper always setsapproverto a valid employee.tests/ui/WorkspaceMemberDetailsPageTest.tsxhas 11 tests, none of which exercises the remove-member path.Separate bug found while tracing (not this crash). When the removed approver is the workspace owner in a single-approver default workflow, the condition
currentApprover?.email !== ownerEmailat:474is false, so the workflow returns unchanged with the removed owner still listed as approver. Worth a separate issue.Runtime verification not obtained. I tried to drive the web build to confirm that the issue's stated four steps do not crash, but the test session came up with a blank page and never recovered, so that check is unverified. It doesn't change the code analysis: the throw needs
defaultApproverto be missing fromemployeeList, which those steps don't create.Useful next step to narrow it further. For the
policyIDs in the Sentry breadcrumbs, check whetherpolicy.approver(or an HRfinalApprover) was absent from that policy'semployeeListat crash time. That distinguishes which of the three data conditions in point 3 the affected accounts hit.Possibly related open issues (neither is a duplicate): #75020 (admin becomes approver when dismissing a delete-approver error) and #94891 (approval workflow mismatch between New and Old Expensify) both touch approver-list correctness.
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/100266#issuecomment-5527827020)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
view run
cretadn22 commentedon Sep 4, 2026
@MelvinBot implement this
MelvinBot commentedon Sep 4, 2026
🤖 Draft PR created: #100370
Please mark it as "Ready for review" when it is ready.
Implemented the proposal as written. Two changes plus three tests:
1. Fix the producer. New shared helper
calculateDefaultWorkflowApproversfalls back to a single approver built fromdefaultApprover, thenpolicy.owner, whencalculateApproverscomes back empty — and returns[]only when there's no usable email at all, in which case the caller skips theunshiftentirely. Used at both sites: the legacy converter and the beta rules converter, which had the same unguarded block copy-pasted.2. Defense in depth. The
flatMapcallback inupdateWorkflowDataOnApproverRemovalnow drops any workflow with no approvers by returning[]. Both call sites are fixed with no change at either. This also covers the second, narrower producer you flagged — the Expensify-team filter re-emptying an array after the in-loop fallback.Left the
throwalone, per your rejected-alternatives section.Tests: all three cases from the proposal are in
tests/unit/WorkflowUtilsTest.ts. I confirmed all three fail onmainand pass on the branch.Local checks
npm test -- tests/unit/WorkflowUtilsTest.tsWorkflowUtils.tschange stashednpm test -- tests/actions/WorkflowTest.ts tests/ui/WorkspaceMemberDetailsPageTest.tsxnpm test -- tests/ui/ApproverSelectionListTest.tsx tests/ui/WorkspaceWorkflowsApprovalsEditPageTest.tsx tests/ui/WorkspaceWorkflowsLoadMoreTest.tsx tests/unit/ApprovalWorkflowSectionTest.tsxnpm run typechecknpm run lint-changednpm run spell-changedNot run:
npm run prettier(no such script inpackage.json; formatting is covered bylint-changed) andnpm run react-compiler-compliance-check(no.tsxsource changed).Runtime verification not obtained. I tried to drive the web build to smoke-test workspace member removal and the workflows page on this branch, but the test session came up as a blank page with zero DOM nodes and never recovered — the same failure the analysis run hit. The unit tests cover the logic; a manual pass on the
Testssteps is still worth doing before this goes up for review.One thing for you to decide.
cretadn22— I couldn't push to your fork, so the branch lives on upstream (claude-defaultApprovalWorkflowMissingApprover). To take ownership and push updates:Or just push to the upstream branch directly if you have access — either works.
The
TestsandQA Stepssections of the PR are left as TODO for you. Reaching the crash needs a workspace where no member submits to the default approver andpolicy.approverisn't a key inemployeeList, so the repro steps in the issue body won't produce it as written.view run
80 remaining items
melvin-bot commentedon Sep 20, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
cretadn22 commentedon Sep 22, 2026
A regression test is not required for this PR. We just need to monitor Sentry to verify whether the bug has been resolved
melvin-bot commentedon Sep 24, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Sep 24, 2026
Payment Summary
Resolving PRs:
[No QA] Drop approver-less workflows when removing an approver #100370
Reviewer: @cretadn22 owed $175 via NewDot
BugZero Checklist (@mallenexpensify)
cretadn22 commentedon Sep 25, 2026
A regression test is not required for this PR. We just need to monitor Sentry to verify whether the bug has been resolved
cretadn22 commentedon Sep 25, 2026
The amount should be $250 since this work was completed prior to the downprice announcement
mallenexpensify commentedon Sep 26, 2026
Payment Summary
Contributor+: @cretadn22 due $250 via NewDot
JmillsExpensify commentedon Nov 4, 2026
$250 approved for @cretadn22