Skip to content

[Due for payment 2026-09-30] [Exploratory] Onboarding - "Submit to my employer" in self DM can submit expense to expired Workspace #99325

Closed

Description

@applause-bot

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


Version Number: v9.4.59-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: https://test-management.browserstack.com/projects/2219752/test-runs/70387620/41237668/1686037950?sort=%2Bidentifier
Email or phone of affected tester (no customers): leungbratt6+0212@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Windows 10/Chrome
App Component: Money Requests

Action Performed:

Precondition: User has only an expired Workspace required payment

  1. Open the New Dot app
  2. Navigate to selfDM
  3. Create a new expense -> select Submit to my employer
  4. Enter the merchant - Create expense

Expected Result:

Verify you are brought to a “Restricted” screen
Verify there is a badge “[Add a payment card to unlock!”]

Actual Result:

Can submit an expense to the expired Workspace with the Submit to my employer in selfDM

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7240559_1787465385888.submit-expired.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Julia Ponikarchuk
Bug ID: 7240559

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. applause-bot commented on Aug 24, 2026

    @applause-bot
    Author

    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

  2. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Sep 5, 2026
  3. MelvinBot commented on Sep 5, 2026

    @MelvinBot
    Contributor

    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.

    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.

    1. 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.
    2. 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.

    Investigation details

    Full path traced: self-DM whisper button (ChatActionableButtons.tsx:249) → createDraftTransactionAndNavigateToParticipantSelector → EMPLOYER branch → count === 1 fast 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-610 and MoneyRequestHeaderSecondaryActions.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 === 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.
    • Why: The restriction is enforced per entry point, not centrally — there is no check in the confirmation page or the IOU action layer. Skipping it lets users create expenses on a workspace with an expired required payment ([Due for payment 2026-09-30] [Exploratory] Onboarding - "Submit to my employer" in self DM can submit expense to expired Workspace #99325).
    • Search pattern: Navigation\.navigate\(ROUTES\.MONEY_REQUEST_STEP_(CONFIRMATION|CATEGORY) or startMoneyRequest\( in a function that mentions policyID/getPolicyExpenseChat but not shouldRestrictUserBillableActions.
    • Offending code (❌): ReportUtils.ts:12374-12388
    • Correct shape (✅): ReportUtils.ts:12271-12275

    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.


    view run · no recording available

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

    @melvin-bot

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

  6. melvin-bot commented on Sep 5, 2026

    @melvin-bot

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

  7. melvin-bot commented on Sep 7, 2026

    @melvin-bot

    @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!

  8. marufsharifi commented on Sep 8, 2026

    @marufsharifi
    Contributor

    @MelvinBot, Draft the pr

  9. 16 remaining items

  10. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Sep 28, 2026
  11. melvin-bot commented on Sep 29, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  12. melvin-bot commented on Sep 29, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  13. mallenexpensify commented on Oct 1, 2026

    @mallenexpensify
    Contributor

    Deploy Blocker #101835 was identified to be related to this PR.

    @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

  14. marufsharifi commented on Oct 1, 2026

    @marufsharifi
    Contributor

    @mallenexpensify, I've accepted the offer. thanks.

  15. marufsharifi commented on Oct 1, 2026

    @marufsharifi
    Contributor

    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.

    @mallenexpensify, sorry for missing this earlier. Based on #101835 (comment), this wasn’t a regression caused by our changes.

    cc @lakchote

  16. mallenexpensify commented on Oct 2, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @marufsharifi paid $250 via Upwork

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorNot a priority

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions