Skip to content

Expense - New report appears briefly after creating new report from self DM #88425

Closed

Description

@mitarachim

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.3.61-0
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #84832
Email or phone of affected tester (no customers): osijdnosijdosjdoij@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.2 / Chrome
App Component: Money Requests

Action Performed:

Precondition:

  • Set Submission to Instantly.
  • Disable Approvals and Payments.
  • Workspace has no open report.
  1. Go to staging.new.expensify.com
  2. Go to self DM..
  3. Create a non-reimbursable expense.
  4. Open the expense.
  5. Click Report field.
  6. Click Create report.
  7. Click Report field.

Expected Result:

In Step 6, report will not appear briefly after creating a new report.

Actual Result:

In Step 6, report appears briefly after creating a new report.
In Step 7, the new report in Step 6 disappears.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7134854_1776774227789.6.mp4

View all open jobs on GitHub

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    DeployBlockerIndicates it should block deploying the API
    on Apr 21, 2026
  2. melvin-bot commented on Apr 21, 2026

    @melvin-bot

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

  3. melvin-bot commented on Apr 21, 2026

    @melvin-bot

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

  4. github-actions commented on Apr 21, 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.
  5. OSBotify commented on Apr 21, 2026

    @OSBotify
    Contributor

    Investigation Summary

    Classification: Frontend bug
    Causing PR: #84832 - "Fix: Filter ineligible reports in useOutstandingReports hook" by @abzokhattab (High confidence)
    Related Issues: #70423 (the original issue PR #84832 was fixing)

    Recommendation: REVERT

    PR #84832 introduced filtering logic in useOutstandingReports that causes newly created reports to disappear from the report selection list under specific workspace conditions, directly matching the reported regression.

    Assigned: @abzokhattab (PR author), @grgia (approving reviewer), @huult (approving reviewer) from highest-confidence causing PR only
    Labels: DeployBlockerCash kept (Frontend bug — App PR caused this). DeployBlocker removed (no backend change required).

    Detailed Analysis

    Evidence

    Verification

    Affected files from PR #84832:

    • src/hooks/useOutstandingReports.ts — the hook consumed by ReportField.tsx (the component rendered when the user clicks the Report field on the confirmation page)

    PR modifies the exact code path triggered by the bug:

    Root Cause

    isReportIneligibleForMoveExpenses in src/libs/ReportUtils.ts (line 2788) returns true when:

    1. The workspace has Instant Submit enabled (autoReporting: true, autoReportingFrequency: INSTANT)
    2. The workspace has Submit & Close (no approvals/payments — approvalMode: OPTIONAL)
    3. The report contains only non-reimbursable transactions (hasOnlyNonReimbursableTransactions returns true)

    The timing issue in the reported bug:

    • Step 6 — "Create report": The freshly created report has zero transactions. hasOnlyNonReimbursableTransactions returns false when there are no transactions (line 2619-2621: if transactions.length === 0 return false). The new report passes the filter and briefly appears.
    • Step 7 — click Report field again: By now the non-reimbursable expense transaction has been optimistically associated with the new report in Onyx. hasOnlyNonReimbursableTransactions now returns true. With Instant Submit + Submit & Close, isReportIneligibleForMoveExpenses returns true, so the new report is filtered out and disappears.

    The PR intended to prevent users from moving expenses to reports that would immediately auto-close (causing a 403 server error), but the filtering is applied too broadly — it also removes the report the user is actively trying to select or just created as a destination.

  6. MelvinBot commented on Apr 21, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    PR #84832 introduced filterEligibleReports in the useOutstandingReports hook, which calls isReportIneligibleForMoveExpenses. This function marks a report as ineligible when:

    1. The policy has instant submit enabled, AND
    2. The policy has submit-and-close (no approvals), AND
    3. The report has only non-reimbursable transactions

    When "Create report" is tapped, createReportForPolicy creates an empty optimistic report (0 transactions) and then moves the transaction in a deferred microtask via setNavigationActionToMicrotaskQueue. During the gap between report creation and transaction move:

    • hasOnlyNonReimbursableTransactions returns false (0 transactions) → report is eligible → it appears
    • Once the transaction is moved, hasOnlyNonReimbursableTransactions returns true → isReportIneligibleForMoveExpenses returns true → report is filtered out → it disappears

    Additionally, the server response to CHANGE_TRANSACTIONS_REPORT likely closes the report entirely (stateNum → APPROVED) for submit-and-close policies with only non-reimbursable transactions, which removes it from the derived OUTSTANDING_REPORTS_BY_POLICY_ID value as well.

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

    In isReportIneligibleForMoveExpenses, add an exemption for reports that are still being created (have pendingFields.createReport === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD), similar to the existing isDraftReport exemption. This prevents the newly-created report from being filtered out before the optimistic flow completes:

    function isReportIneligibleForMoveExpenses(moneyRequestReport, policy) {
        if (isDraftReport(moneyRequestReport?.reportID)) {
            return false;
        }
        if (moneyRequestReport?.pendingFields?.createReport === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD) {
            return false;
        }
        return isInstantSubmitEnabled(policy) && isSubmitAndClose(policy) && hasOnlyNonReimbursableTransactions(moneyRequestReport?.reportID);
    }
    

    This ensures the report remains visible during the optimistic create → move flow. Once the server confirms the creation (clearing pendingFields.createReport), the normal eligibility logic takes over.

    What alternative solutions did you explore? (Optional)

    An alternative would be to make changeTransactionsReport run synchronously with createNewReport instead of being deferred to a microtask, but that would require changes to the navigation flow and could introduce other timing issues.

    Investigation details

    Key code locations:

    • src/hooks/useOutstandingReports.ts:25-29 — filterEligibleReports introduced by PR Fix: Filter ineligible reports in useOutstandingReports hook #84832
    • src/libs/ReportUtils.ts:2788-2793 — isReportIneligibleForMoveExpenses
    • src/libs/ReportUtils.ts:2617-2624 — hasOnlyNonReimbursableTransactions returns false for 0 transactions
    • src/pages/iou/request/step/IOURequestStepReport.tsx:239-247 — createReportForPolicy creates report then defers transaction move
    • src/libs/ReportUtils.ts:6916-6962 — buildOptimisticEmptyReport sets pendingFields.createReport = ADD
    • src/libs/actions/OnyxDerived/configs/outstandingReportsByPolicyID.ts:25-30 — derived value filters reports with stateNum <= SUBMITTED

    Data flow:

    1. User clicks "Create report" → createNewReport writes empty optimistic report to Onyx (0 transactions, pendingFields.createReport = ADD)
    2. Report passes filterEligibleReports (0 transactions → not ineligible) → appears in list
    3. Microtask fires → changeTransactionsReport moves non-reimbursable transaction to report
    4. hasOnlyNonReimbursableTransactions now returns true → isReportIneligibleForMoveExpenses returns true → report filtered out
    5. Server response likely closes report (stateNum → APPROVED) → removed from derived outstanding reports

    Reproducible in production? No — this is staging-only per the issue report, which aligns with the hypothesis since submit-and-close behavior may differ between environments.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  7. huult commented on Apr 21, 2026

    @huult
    Contributor

    @abzokhattab could you check this issue?

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.EngineeringHourlyKSv2ReviewingHas a PR in review

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions