Skip to content

Spend - RHP loads infinitelly after merging Self DM expense with workspace expense offline. #92846

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.0.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: #89360
Email or phone of affected tester (no customers): ibellicotest+2766@gmail.com
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: Motorola MotoG60 / Android 12 (Hybrid app) - Windows 11 / Chrome
App Component: Search

Action Performed:

Prerequisite: Account has Self DM.
Prerequisite 2: Account has at least one workspace.

  1. Open the staging.new.expensify.com website.
  2. Create an expense in self DM.
  3. Create an expense in workspace chat.
  4. Go to Spend > Expenses.
  5. Turn off internet connection.
  6. Select the workspace expense via the checkbox.
  7. Click the dropdown button > Merge.
  8. Select self DM expense > Continue.
  9. Select the second option in each section > Next > Merge expenses.
  10. Note that infinite loading is displayed when RHP is opened.

Expected Result:

After meging expense from Self DM with workspace expense while on "Spend", user should automatically land on transaction thread.

Actual Result:

After merging expense from Self DM with workspace expense while on "Expenses" section on "Spend", RHP is displayed with infinite loading.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7172999_1780690780599.RHP.mp4

View all open jobs on GitHub

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

Activity

  1. applause-bot commented on Jun 6, 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/26b60b8eb1d62b0050c78b6fae37ace45070ecafacd480b72ccb0ca9e3b98a4c

  2. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jun 6, 2026
  3. melvin-bot commented on Jun 6, 2026

    @melvin-bot

    @MonilBhavsar recently merged #89360, but they are OOO right now, so I'll auto-assign someone else.

  4. melvin-bot commented on Jun 6, 2026

    @melvin-bot

    Triggered auto assignment to @NicolasBonet (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  5. melvin-bot commented on Jun 6, 2026

    @melvin-bot

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

  6. github-actions commented on Jun 6, 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.
  7. godzillaxbox19982014-lgtm commented on Jun 6, 2026

    @godzillaxbox19982014-lgtm

    Proposal

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

    Spend - RHP loads infinitelly after merging Self DM expense with workspace expense offline.

    What is the root cause of that problem?

    I traced this to the path that handles workspace name, expense report, DM:

    • src/pages/iou/request/step/confirmation/useExpenseSubmission.ts:219 (existingInvoiceReport): const existingInvoiceReport = useParticipantsInvoiceReport(receiverAccountID, receiverType, senderWorkspaceID);
    • src/pages/iou/request/step/confirmation/useExpenseSubmission.ts:195 (hasViolations): const hasViolations = hasViolationsReportUtils(report?.reportID, transactionViolations, currentUserPersonalDetails.accountID, currentUserPersonalDetails.login ?? '');
    • src/pages/iou/request/step/confirmation/useExpenseSubmission.ts:217 (senderWorkspaceID): const senderWorkspaceID = transaction?.participants?.find((p) => p?.isSender)?.policyID;
    • The local evidence matches this recurring failure shape: optimistic transaction/report data is written to one Onyx key but the visible list reads another derived key. Here, src/pages/iou/request/step/confirmation/useExpenseSubmission.ts:219 and src/pages/iou/request/step/confirmation/useExpenseSubmission.ts:195 do not agree on the same workspace name, expense report, DM value, so the user-visible path can show a missing or stale state even though nearby data already has the needed context.

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

    • Update src/pages/iou/request/step/confirmation/useExpenseSubmission.ts:219 to derive workspace name, expense report, DM from the report/transaction source that owns this flow before the value is consumed.
    • Carry the same normalized value through src/pages/iou/request/step/confirmation/useExpenseSubmission.ts:195; that follows the safer family move to align optimistic/success/failure data with the selector consumed by the screen, so the write/optimistic/read paths agree instead of only changing the visible component.
    • Keep the change inside the Reports, Expenses, IOU, Transactions surface and avoid changing payment actions, personal/deleted policies.

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    1. Add or update a regression in tests/unit/ReportUtils*.ts for the exact issue flow: Spend - RHP loads infinitelly after merging Self DM expense with workspace expense offline..
    2. Cover the counter-case near src/pages/iou/request/step/confirmation/useExpenseSubmission.ts:219 so valid existing workspace name, expense report, DM behavior still works.
    3. Manually repeat the issue steps after the patch and confirm the visible state/action is no longer stale.

    What alternative solutions did you explore? (Optional)

    • I would not add a broad new condition outside these referenced paths; the safer fix is to keep workspace name, expense report, DM consistent at the first read/write boundary shown above.
  8. MelvinBot commented on Jun 6, 2026

    @MelvinBot
    Contributor

    Proposal

    🤖 Automated analysis — high confidence. This is a regression from PR #89360 (in the current staging deploy), which is why it reproduces in staging but not production.

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

    When merging a Self DM expense with a workspace expense while offline from Reports > Expenses (Spend), the RHP that opens after the merge shows an infinite loading skeleton instead of landing on the transaction thread.

    What is the root cause of that problem?

    PR #89360 changed the post-merge navigation target. The app now navigates to the target transaction's thread report instead of the destination chat report:

    // src/pages/TransactionMerge/ConfirmationPage.tsx
    const targetTransactionThreadReportID = mergeTransaction?.targetTransactionThreadReportID ?? getTransactionThreadReportID(targetTransaction);
    const searchReportIDToOpen = targetTransactionThreadReportID ?? reportIDToDismiss;
    Navigation.navigate(ROUTES.SEARCH_REPORT.getRoute({reportID: searchReportIDToOpen}));

    That thread report exists in Onyx (the merge reparents it), but its REPORT_ACTIONS_<id> collection is empty — no OpenReport was ever called for it, and mergeTransactionRequest does not seed an optimistic CREATED action for it. When the RHP mounts, ReportFetchHandler fires OpenReport, which optimistically sits in the persisted request queue and never completes offline.

    The infinite skeleton then comes from this offline-only footer condition:

    // src/pages/inbox/report/ReportActionsList.tsx:628
    const shouldShowSkeleton = isOffline && !sortedVisibleReportActions.some((action) => action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED);

    With no report actions loaded, there is no CREATED action, so offline this stays true forever and the skeleton is the entire visible content. Before the PR, navigation went to the destination chat report (e.g. self DM / workspace chat), which already had its CREATED action in Onyx, so the skeleton never showed offline.

    Evidence chain (file:line)

    Note: isLoadingInitialReportActions is not the cause — every check of it in ReportActionsView.tsx is gated on !isOffline. The freeze is specifically the isOffline && !some(CREATED) footer skeleton.

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

    Recommended (targeted): in ConfirmationPage.tsx, only navigate to the transaction thread when its report actions are actually available; otherwise fall back to the destination report (reportIDToDismiss), preserving the pre-PR offline behavior. Concretely, when isOffline (or when REPORT_ACTIONS_<targetTransactionThreadReportID> has no CREATED action), set searchReportIDToOpen = reportIDToDismiss.

    Alternative: seed an optimistic CREATED report action into REPORT_ACTIONS_<targetTransactionThreadReportID> inside mergeTransactionRequest when the thread is reparented, so the offline skeleton condition is satisfied and the thread renders immediately.

    Because this is a DeployBlockerCash, reverting PR #89360 is a valid fast path if a targeted fix can't be verified offline quickly.

    Related issues


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/92846) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.

  9. NicolasBonet commented on Jun 8, 2026

    @NicolasBonet
    Contributor

    @MelvinBot can you find the offending PR?

  10. MelvinBot commented on Jun 8, 2026

    @MelvinBot
    Contributor

    The offending PR is #89360 — "Fix bulk expense merge opening self DM instead of transaction thread" (author marufsharifi, merged 2026-06-04, currently in the staging deploy — which is why this reproduces in staging but not production).

    Why it's the cause: That PR changed the post-merge navigation target to the target transaction's thread report instead of the destination chat report (ConfirmationPage.tsx — targetTransactionThreadReportID = mergeTransaction?.targetTransactionThreadReportID ?? getTransactionThreadReportID(targetTransaction)). Offline, that thread report has no CREATED action loaded, so the offline-only skeleton condition in ReportActionsList.tsx:628 (isOffline && !some(action === CREATED)) stays true forever → infinite skeleton.

    Verification
    • PR title and scope match exactly: it touches ConfirmationPage.tsx, MergeTransactionUtils.ts, and MergeTransaction.ts — the precise files in the merge-navigation flow.
    • The navigation behavior change is in the diff: getTransactionThreadReportID(targetTransaction) → mergeTransaction?.targetTransactionThreadReportID ?? getTransactionThreadReportID(targetTransaction).
    • It also matches the issue's own metadata (melvin-bot auto-assignment flagged MonilBhavsar's merge of Fix bulk expense merge opening self DM instead of transaction thread #89360, and the BrowserStack field links the same PR).
    • Regression timeline is consistent: merged 2026-06-04, reported 2026-06-06, staging-only.

    Since this is a DeployBlockerCash, reverting #89360 is the fast path; the targeted fix (fall back to the destination report when offline / when the thread has no CREATED action) is described in the proposal above.

  11. NicolasBonet commented on Jun 8, 2026

    @NicolasBonet
    Contributor

    @MelvinBot let's create a revert PR

  12. MelvinBot commented on Jun 8, 2026

    @MelvinBot
    Contributor

    🤖 Draft revert PR created: #92934

    This is a clean revert of merge commit e07b8f42a1c4d2db5960827786baea87ba4d4390 (git revert -m 1) — 15 files changed, matching #89360's footprint.

    Local AI tests (all passed):

    • npm run typecheck ✅
    • npm run lint-changed ✅
    • npm test on the merge-transaction suites (MergeTransactionTest, MergeTransactionUtilsTest, useSelectedTransactionsActions.test) ✅ — 119 tests passed

    Please fill out the human-only Tests / QA sections and mark it "Ready for review" when ready.

  13. NicolasBonet commented on Jun 8, 2026

    @NicolasBonet
    Contributor

    PR reverted, waiting for staging deployment

  14. m-natarajan commented on Jun 8, 2026

    @m-natarajan

    Reproduced, Chrome / v9.4.0-2 (Waiting for Android validation)

    REC-20260608211901.mp4
  15. m-natarajan commented on Jun 8, 2026

    @m-natarajan

    Not reproduced, Chrome / v9.4.0-4 , Xiaomi Redmi Note 10 / Android 12

    REC-20260608223444.mp4
    Screenrecorder-2026-06-08-22-47-55-46.mp4
  16. NicolasBonet commented on Jun 8, 2026

    @NicolasBonet
    Contributor

    Thank you! That solves the issue.

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

Metadata

Metadata

Assignees

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