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
[Due for payment 2026-09-30] [Exploratory] Onboarding - "Submit to my employer" in self DM can submit expense to expired Workspace #99325
The billing-restriction gate lives in the workspace picker, and "Submit to my employer" skips the picker when you belong to exactly one workspace.
createDraftTransactionAndNavigateToParticipantSelector has a fast path for the EMPLOYER destination: if the user has one accessible workspace, it binds the draft to that workspace's expense chat and navigates straight to the confirmation page — src/libs/ReportUtils.ts:12374-12388.
The only place the SUBMIT flow calls shouldRestrictUserBillableActions and redirects to ROUTES.RESTRICTED_ACTION is the picker row handler at src/pages/iou/request/ParticipantSearchResults.tsx:495-506. Skip the picker → skip the gate. Nothing downstream re-checks: the confirmation page, confirmAction, the validation hook, and TrackExpense.requestMoney contain zero billing-restriction checks, so the expense is created against the expired workspace.
This is why the bug needs the exact preconditions in the report: one workspace, and it's expired. With two or more workspaces you hit the picker and correctly land on the Restricted screen.
The count that drives the fast path comes from a shouldShowPolicy-based selector (src/selectors/Policy.ts:353-371), which only filters archived/personal/pending-delete policies — an expired workspace still counts as accessible.
What changes do you think we should make in order to solve the problem?
Apply the same gate the sibling CATEGORIZE branch already applies, before the single-workspace fast path navigates.
In the EMPLOYER branch of createDraftTransactionAndNavigateToParticipantSelector, resolve the policy for firstPolicyID and, if shouldRestrictUserBillableActions(...) is true, Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(firstPolicyID)) and return — mirroring src/libs/ReportUtils.ts:12271-12275. All four required inputs (ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, currentUserAccountID) are already threaded into this function for that CATEGORIZE check, so no new plumbing is needed.
Give the preferred-policy fast path just below it the same guard — src/libs/ReportUtils.ts:12408-12419 skips the picker the same way and is also ungated today.
Fixing it inside this helper covers all three "Submit to my employer" entry points at once, since they all call it: the self-DM whisper buttons, the report-details menu, and the expense header menu.
The expected badge is owner-only, which matches the report: workspace.restrictedAction.addPaymentCardToUnlock renders only in WorkspaceOwnerRestrictedAction.
What alternative solutions did you explore? (Optional)
Filtering restricted workspaces out of the filteredPoliciesCount selector. Rejected: it would push the single-expired-workspace case into the count === 0 branch, which silently spins up a brand-new Submit workspace instead of showing the Restricted screen.
Guards that run before the write: field validation only (amount, merchant, category/tag out-of-policy, attendees, tax, distance) plus a double-submit guard and, for PAY, a delegate-access check. No billing-restriction check anywhere in that chain.
Contrast with a working entry point: the workspace-chat "Add expense" path gates correctly at ReportUtils.ts:3298-3305, which is why other flows show the Restricted screen.
When the branch was introduced: the EMPLOYER branch and its ungated count === 1 fast path were added in #94319 (merged 2026-07-13), which predates the reported v9.4.59-0.
Alternative explanations considered and ruled out: (a) the restriction genuinely not being active — ruled out because the reporter's precondition is an expired required payment and the expected screen is the owner variant, which is exactly the isPolicyOwner + amountOwed > 0 + past ownerBillingGracePeriodEnd limb of the predicate; (b) a backend-side gap — ruled out because the gate is entirely client-side navigation, with no server enforcement in this flow to fall back on.
Runtime verification: I attempted to drive the flow on web to confirm the picker is skipped with a single workspace, but the test session never rendered the app (blank page, no network activity), so this analysis rests on code evidence only. The expired-workspace state itself isn't reproducible from a fresh test account regardless, since it depends on billing NVPs.
💡 Suggested AI code review rule
This is a recurring, mechanically detectable pattern — shouldRestrictUserBillableActions is duplicated across roughly 40 entry points, and every new one that routes an expense into a workspace has to remember it. Proposed for Expensify/App:
Rule:CONSISTENCY-19 — Gate every workspace-bound expense entry point on shouldRestrictUserBillableActions
Condition: Flag any new or modified code path that resolves a policyID/policy expense chat and then navigates to expense creation (MONEY_REQUEST_STEP_CONFIRMATION, MONEY_REQUEST_STEP_CATEGORY, startMoneyRequest) without first calling shouldRestrictUserBillableActions and redirecting to ROUTES.RESTRICTED_ACTION. Applies with extra force to "fast paths" that auto-select a single workspace and skip a picker, since the picker is usually where the gate lives.
Search pattern:Navigation\.navigate\(ROUTES\.MONEY_REQUEST_STEP_(CONFIRMATION|CATEGORY) or startMoneyRequest\( in a function that mentions policyID/getPolicyExpenseChat but not shouldRestrictUserBillableActions.
The full rule file would live in Expensify/App's .claude/skills/coding-standards/rules/. If it's worth adding, a maintainer can open it there as a draft PR.
Related issues
No likely duplicates found. Possibly related: #98998 (locked bank account modal not shown after going online) — a different subsystem, but the same shape of a restriction screen failing to appear.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/99325) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
@marufsharifi this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
Thanks, @marufsharifi. It’s true that the back-navigation code predates your PR. Your change now makes this path reachable in this flow, exposing the existing issue, so we should fix it.
Activity
applause-bot commentedon Aug 24, 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/28da0e5a5ec55e30ce0f6942566d0eea02e698036a3b0c0c1902ef17b92c7203
MelvinBot commentedon Sep 5, 2026
Proposal
What is the root cause of that problem?
The billing-restriction gate lives in the workspace picker, and "Submit to my employer" skips the picker when you belong to exactly one workspace.
createDraftTransactionAndNavigateToParticipantSelectorhas a fast path for the EMPLOYER destination: if the user has one accessible workspace, it binds the draft to that workspace's expense chat and navigates straight to the confirmation page —src/libs/ReportUtils.ts:12374-12388.The only place the SUBMIT flow calls
shouldRestrictUserBillableActionsand redirects toROUTES.RESTRICTED_ACTIONis the picker row handler atsrc/pages/iou/request/ParticipantSearchResults.tsx:495-506. Skip the picker → skip the gate. Nothing downstream re-checks: the confirmation page,confirmAction, the validation hook, andTrackExpense.requestMoneycontain zero billing-restriction checks, so the expense is created against the expired workspace.This is why the bug needs the exact preconditions in the report: one workspace, and it's expired. With two or more workspaces you hit the picker and correctly land on the Restricted screen.
The count that drives the fast path comes from a
shouldShowPolicy-based selector (src/selectors/Policy.ts:353-371), which only filters archived/personal/pending-delete policies — an expired workspace still counts as accessible.What changes do you think we should make in order to solve the problem?
Apply the same gate the sibling CATEGORIZE branch already applies, before the single-workspace fast path navigates.
createDraftTransactionAndNavigateToParticipantSelector, resolve the policy forfirstPolicyIDand, ifshouldRestrictUserBillableActions(...)is true,Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(firstPolicyID))and return — mirroringsrc/libs/ReportUtils.ts:12271-12275. All four required inputs (ownerBillingGracePeriodEnd,userBillingGracePeriodEnds,amountOwed,currentUserAccountID) are already threaded into this function for that CATEGORIZE check, so no new plumbing is needed.src/libs/ReportUtils.ts:12408-12419skips the picker the same way and is also ungated today.Fixing it inside this helper covers all three "Submit to my employer" entry points at once, since they all call it: the self-DM whisper buttons, the report-details menu, and the expense header menu.
The expected badge is owner-only, which matches the report:
workspace.restrictedAction.addPaymentCardToUnlockrenders only inWorkspaceOwnerRestrictedAction.What alternative solutions did you explore? (Optional)
Filtering restricted workspaces out of the
filteredPoliciesCountselector. Rejected: it would push the single-expired-workspace case into thecount === 0branch, which silently spins up a brand-new Submit workspace instead of showing the Restricted screen.Investigation details
Full path traced: self-DM whisper button (
ChatActionableButtons.tsx:249) →createDraftTransactionAndNavigateToParticipantSelector→ EMPLOYER branch →count === 1fast path →MONEY_REQUEST_STEP_CONFIRMATION→buildConfirmAction→SubmitExpenseOrchestrator.onConfirm→useExpenseSubmission.createTransaction→requestMoney→convertTrackedExpenseToRequest→API.write(CONVERT_TRACKED_EXPENSE_TO_REQUEST).Guards that run before the write: field validation only (amount, merchant, category/tag out-of-policy, attendees, tax, distance) plus a double-submit guard and, for PAY, a delegate-access check. No billing-restriction check anywhere in that chain.
The other two "Submit to my employer" entry points —
DynamicReportDetailsPage.tsx:596-610andMoneyRequestHeaderSecondaryActions.tsx:652-669— call the same helper, so they share the bug.Contrast with a working entry point: the workspace-chat "Add expense" path gates correctly at
ReportUtils.ts:3298-3305, which is why other flows show the Restricted screen.When the branch was introduced: the EMPLOYER branch and its ungated
count === 1fast path were added in #94319 (merged 2026-07-13), which predates the reported v9.4.59-0.Alternative explanations considered and ruled out: (a) the restriction genuinely not being active — ruled out because the reporter's precondition is an expired required payment and the expected screen is the owner variant, which is exactly the
isPolicyOwner + amountOwed > 0 + past ownerBillingGracePeriodEndlimb of the predicate; (b) a backend-side gap — ruled out because the gate is entirely client-side navigation, with no server enforcement in this flow to fall back on.Runtime verification: I attempted to drive the flow on web to confirm the picker is skipped with a single workspace, but the test session never rendered the app (blank page, no network activity), so this analysis rests on code evidence only. The expired-workspace state itself isn't reproducible from a fresh test account regardless, since it depends on billing NVPs.
💡 Suggested AI code review rule
This is a recurring, mechanically detectable pattern —
shouldRestrictUserBillableActionsis duplicated across roughly 40 entry points, and every new one that routes an expense into a workspace has to remember it. Proposed forExpensify/App:CONSISTENCY-19— Gate every workspace-bound expense entry point onshouldRestrictUserBillableActionspolicyID/policy expense chat and then navigates to expense creation (MONEY_REQUEST_STEP_CONFIRMATION,MONEY_REQUEST_STEP_CATEGORY,startMoneyRequest) without first callingshouldRestrictUserBillableActionsand redirecting toROUTES.RESTRICTED_ACTION. Applies with extra force to "fast paths" that auto-select a single workspace and skip a picker, since the picker is usually where the gate lives.Navigation\.navigate\(ROUTES\.MONEY_REQUEST_STEP_(CONFIRMATION|CATEGORY)orstartMoneyRequest\(in a function that mentionspolicyID/getPolicyExpenseChatbut notshouldRestrictUserBillableActions.ReportUtils.ts:12374-12388ReportUtils.ts:12271-12275The full rule file would live in
Expensify/App's.claude/skills/coding-standards/rules/. If it's worth adding, a maintainer can open it there as a draft PR.Related issues
No likely duplicates found. Possibly related: #98998 (locked bank account modal not shown after going online) — a different subsystem, but the same shape of a restriction screen failing to appear.
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/99325)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
view run · no recording available
melvin-bot commentedon Sep 5, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @marufsharifi (
External)melvin-bot commentedon Sep 5, 2026
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.
melvin-bot commentedon Sep 7, 2026
@marufsharifi this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
marufsharifi commentedon Sep 8, 2026
@MelvinBot, Draft the pr
16 remaining items
melvin-bot commentedon Sep 29, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Sep 29, 2026
Payment Summary
Resolving PRs:
Gate "Submit to my employer" on the workspace billing restriction #100584
Assignee: @marufsharifi requires payment (Needs manual offer from BZ)
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Oct 1, 2026
@marufsharifi , please address the above. can you please accept the job below? Please reply here and tag me once you have.
https://www.upwork.com/jobs/~022105716393396081563
marufsharifi commentedon Oct 1, 2026
@mallenexpensify, I've accepted the offer. thanks.
marufsharifi commentedon Oct 1, 2026
@mallenexpensify, sorry for missing this earlier. Based on #101835 (comment), this wasn’t a regression caused by our changes.
cc @lakchote
mallenexpensify commentedon Oct 2, 2026
Payment Summary
Contributor+: @marufsharifi paid $250 via Upwork