Skip to content

[Due for payment 2026-09-15] Expense - Failed scan expense does not move to a new report after marking as paid offline #96257

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.4.35-1
Reproducible in staging?: Yes
Reproducible in production?: N/A - new feature, doesn't exist in prod
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #95682
Email or phone of affected tester (no customers): dosodjnosjdoisjoi@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.5 / Chrome
App Component: Money Requests

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Create a manual expense.
  4. Create a scan expense with invalid receipt.
  5. Wait for smartscan to fail.
  6. Open the report.
  7. Go offline.
  8. Click Submit, Approve and Mark as paid.
  9. Go online.

Expected Result:

In Step 8. after marking the report as paid in offline mode, the failed scan expense will move to a new report.

Actual Result:

In Step 8. after marking the report as paid in offline mode, the failed scan expense does not move to a new report.
In Step 9, the failed scan expense only moves to a new report after returning online.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7209607_1784186622706.5.mp4

View all open jobs on GitHub

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

Issue OwnerCurrent Issue Owner: @yusufdeveloper2903

Activity

  1. added
    DeployBlockerCash
    Bug
    on Jul 16, 2026
  2. applause-bot commented on Jul 16, 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/78387e4fd33b6a229ce19a4d2c91fc8b0397f503a324cda03a3573dd7d8ba3c0

  3. melvin-bot commented on Jul 16, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #95682

  4. melvin-bot commented on Jul 16, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  5. github-actions commented on Jul 16, 2026

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  6. MelvinBot commented on Jul 16, 2026

    @MelvinBot
    Contributor

    Issue Analysis

    Root Cause: Moving a SmartScan-failed expense out of a report into a new report on Submit/Approve/Pay is done only by the backend response — the App has no optimistic (client-side) logic for it. So offline the split can't happen; it reconciles the moment the queued command is processed after reconnect. This is expected given the current architecture, not a broken state.

    The only report-splitting the App does optimistically is the held-expenses split in Hold.ts:707 (via getReportFromHoldRequestsOnyxData), and it selects transactions strictly by transaction.comment.hold at Hold.ts:598-615 — never by scan-failed status, and only for a partial (!full) action. There is no hasSmartScanFailed / isTransactionSubmittable check feeding any optimistic report split in the Pay/Approve/Submit builders.

    This is not caused by PR #95682 (the PR this deploy blocker was auto-assigned from by merge timing). That PR only changed the Submit button/To-Do visibility logic (isSubmitAction / canSubmitReport); it does not touch optimistic data or the move-to-new-report behavior. Recommend removing the DeployBlockerCash label — nothing in that PR regressed this, and the behavior is a pre-existing offline limitation of a backend-only feature.

    Recommended Fix (if the offline UX is deemed worth fixing): Add an optimistic split in the Pay/Approve/Submit builders that mirrors the held-expenses split but keys off scan-failed / non-submittable transactions (e.g. reuse isTransactionSubmittable / hasSmartScanFailedWithMissingFields from TransactionUtils), building an optimistic new report with buildOptimisticExpenseReport and reassigning those transactions' reportID. This must exactly mirror what the server does, so it's a non-trivial change and not deploy-blocker-urgent.

    Investigation details & evidence
    • Submit — ReportWorkflow.ts submitReport builds optimistic data that only flips stateNum/statusNum/nextStep on the same report; SubmitReportParams carries no move/new-report fields.
    • Approve — ReportWorkflow.ts:742-761: the only split is the held-expenses one, gated behind !full.
    • Pay — PayMoneyRequest.ts:502-514: same held-only split, also gated behind !full. No scan-failed detection.
    • The split mechanism — getReportFromHoldRequestsOnyxData (Hold.ts:707) builds an optimistic new report and moves transactions, but only those returned by getHoldReportActionsAndTransactions, which filters on transaction?.comment?.hold at Hold.ts:598-615.
    • Detection helper exists but isn't wired in — hasSmartScanFailedWithMissingFields / isTransactionSubmittable live in TransactionUtils and are used only for button-enablement (canSubmitReport), never for an optimistic report split.

    Data flow (offline): User taps Pay/Approve/Submit → optimistic builders run → only the held-expenses split path exists, and scan-failed transactions aren't held → nothing moves → command queues → on reconnect the backend performs the split and returns updated Onyx data → only now does the moved expense appear. That exactly matches the reported symptom.

    Alternative explanations considered: A regression from #95682 (ruled out — it only changes Submit visibility), or a broken/lost-data state (ruled out — the expense reconciles correctly once online; it's a delayed-optimistic-UI gap, not data loss).

    Confidence: High on the code mechanism (no optimistic move path exists) and on #95682 not being the cause. Not log-verified that the backend performs the split online, but the reporter confirms the expense moves after reconnecting, which is consistent.


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/96257) to create a draft PR that adds the optimistic split.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal (e.g. if paying-with-a-scan-failed-expense-offline is intended to remain a backend-only, online-only reconciliation).

  7. Pintu-Jha commented on Jul 16, 2026

    @Pintu-Jha

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When marking a report as paid offline, failed scan expenses (or expenses with violations) do not move to a new report. They stay in the current report and only move later when the app goes back online.

    What is the root cause of that problem?

    When you mark a report as paid offline, the app performs an "optimistic update" to show the payment instantly. It uses a helper function called getReportFromHoldRequestsOnyxData (in src/libs/actions/IOU/Hold.ts) to split unpayable expenses into a new report.
    There are two missing pieces in the current logic:

    1. The payment action assumes everything is payable: The payMoneyRequest function defaults to full = true. Because full is true, it completely bypasses the splitting logic.
    2. The splitting logic only checks for "held" expenses: Even if we enabled the split, getReportFromHoldRequestsOnyxData only separates expenses that are on hold (transaction?.comment?.hold). It completely ignores expenses with blocking violations (like failed SmartScans or missing receipts).
      Because of this, the frontend keeps the failed scans in the paid report, while the backend correctly splits them out when it processes the payment later.

    What changes do you think we should make in order to solve the problem?

    We need to update the frontend's optimistic update to match the backend's behavior: it should split out both held transactions and transactions with violations.
    1. Update the split logic in src/libs/actions/IOU/Hold.ts
    Rename getHoldReportActionsAndTransactions to getUnpayableReportActionsAndTransactions. Update it to also check for blocking violations:

    // Fetch the violations for the transaction
    const transactionViolations = getAllTransactionViolations()?.[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`];
    const hasBlockingViolation = transactionViolations?.some((violation) => violation.type === CONST.VIOLATION_TYPES.VIOLATION);
    // Split if it's on hold OR has a blocking violation
    if (transaction?.comment?.hold || hasBlockingViolation) {
        unpayableReportActions.push(action as OnyxTypes.ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.IOU>);
        unpayableTransactions.push(transaction);
    }

    2. Pass the correct full flag when paying
    In the UI components where payment happens (PayPrimaryAction.tsx, PayActionButton.tsx, and MoneyReportHeaderSecondaryActions.tsx), we need to check for violations and held expenses, and pass that to payMoneyRequest.

    // Calculate if there are violations or held expenses
    const hasViolations = hasViolationsReportUtils(moneyRequestReport?.reportID, allTransactionViolations, accountID, email ?? '');
    const hasHeldExpenses = hasHeldExpensesReportUtils(Object.values(reportTransactions));
    // Pass full = false if there are unpayable expenses
    payMoneyRequest({
        ...
        full: !(hasViolations || hasHeldExpenses), 
    });

    3. Update payMoneyRequest and approveMoneyRequest
    Ensure both actions use the newly updated getReportFromUnpayableRequestsOnyxData helper so that when full is false, they properly move both held and failed scan expenses into the new optimistic report.
    This perfectly aligns the offline behavior with the backend.

  8. jasperhuangg commented on Jul 16, 2026

    @jasperhuangg
    Contributor

    This can be demoted because it's behind the beta.

  9. removed
    DeployBlockerCash
    Hourly
    on Jul 16, 2026
  10. 65 remaining items

  11. yusufdeveloper2903 commented on Sep 18, 2026

    @yusufdeveloper2903
    Contributor

    @mallenexpensify Thanks for checking. I agree with $125 for this one

  12. melvin-bot commented on Sep 18, 2026

    @melvin-bot

    @brunovjk Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  13. mallenexpensify commented on Sep 19, 2026

    @mallenexpensify
    Contributor

    @deetergp 👀 above please. Thx

  14. deetergp commented on Sep 19, 2026

    @deetergp
    Contributor

    Agreed that $125 sounds like the right amount 👍

  15. melvin-bot commented on Sep 19, 2026

    @melvin-bot

    @mallenexpensify — to hire @yusufdeveloper2903 on Upwork, add the External label so a job is created and the offer is sent automatically.

  16. mallenexpensify commented on Sep 19, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @yusufdeveloper2903 paid $125 via Upwork
    Contributor+: @brunovjk due $125 via NewDot

    @yusufdeveloper2903 can you please accept the job below? Please reply here and tag me once you have.
    https://www.upwork.com/jobs/~022101108479971088512

  17. yusufdeveloper2903 commented on Sep 19, 2026

    @yusufdeveloper2903
    Contributor

    @mallenexpensify Thanks! I've accepted the job offer on Upwork

  18. added
    Daily
    and removed
    Daily
    on Sep 20, 2026
  19. laurenreidexpensify commented on Sep 21, 2026

    @laurenreidexpensify
    Contributor

    Approved $125 @brunovjk New Expensify

  20. mallenexpensify commented on Sep 21, 2026

    @mallenexpensify
    Contributor

    @yusufdeveloper2903 paid, summary updated above. Thx.

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

Metadata

Metadata

Labels

Awaiting PaymentBugDailyEngineering

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions