Skip to content

[$250] Expense - Different destination opens when bulk merging vs merging individually #83257

Open

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.25-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: #79766
Email or phone of affected tester (no customers): jsodjsodnjoisjdosij@gmail.com
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: Mac 26.2 / Chrome
App Component: Money Requests

Action Performed:

  1. Go to staging.new.expensify.com

  2. Create an expense in self DM.

  3. Create an expense in workspace chat.

  4. Go to Reports > Expenses.

  5. Open the workspace expense.

  6. Click More > Merge.

  7. Select self DM expense > Continue.

  8. Select second option in each section > Next > Merge expenses.
    → Transaction thread opens.

  9. Create an expense in self DM.

  10. Create an expense in workspace chat.

  11. Go to Reports > Expenses.

  12. Select workspace expense via checkbox.

  13. Click dropdown button > Merge.

  14. Select self DM expense > Continue.

  15. Select second option in each section > Next > Merge expenses.

Expected Result:

Transaction thread will open after merging expenses via bulk option (similar to Step 8).

Actual Result:

Self DM opens after merging expenses via bulk option.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7086423_1771884485618.5.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @rojiphil
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022026066651163126006
  • Upwork Job ID: 2026066651163126006
  • Last Price Increase: 2026-02-23

Activity

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

    @melvin-bot

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

  3. melvin-bot commented on Feb 23, 2026

    @melvin-bot

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

  4. melvin-bot commented on Feb 23, 2026

    @melvin-bot

    Triggered auto assignment to @jliexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  5. github-actions commented on Feb 23, 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. OSBotify commented on Feb 23, 2026

    @OSBotify
    Contributor

    🔍 Investigation Summary

    Classification: Frontend bug
    Causing PR: #79766 - "Fix incorrect chat opening after merging expense with self DM" by @marufsharifi (High confidence)
    Related Issues: #78842

    Recommendation: REVERT

    PR #79766 introduced a regression in bulk merge navigation. While it fixed individual merge navigation, it broke bulk merge by causing it to navigate to the parent chat instead of the transaction thread.

    Labels: Keeping DeployBlockerCash (App PR caused the issue), removing DeployBlocker (not a backend issue)


    📋 Detailed Analysis

    Evidence

    PR #79766 was merged on 2026-02-23 (same day as this deploy blocker was reported) and is listed in the StagingDeployCash issue #83247. The PR modified src/pages/TransactionMerge/ConfirmationPage.tsx to change how navigation works after merging expenses, specifically to handle self DM expense merges.

    The issue report explicitly states:

    • Individual merge (steps 1-8): Works correctly - transaction thread opens
    • Bulk merge (steps 9-15): Broken - self DM opens instead of transaction thread

    This matches the scope of changes in PR #79766, which modified the navigation logic in the confirmation page.

    Verification

    PR #79766 modified only one file: src/pages/TransactionMerge/ConfirmationPage.tsx

    The key changes were:

    1. Line 74: Added logic to determine reportID - if merge transaction reportID is UNREPORTED_REPORT_ID, it falls back to self DM report ID
    2. Lines 97-105: Changed navigation logic to use ROUTES.SEARCH_REPORT for all search-based merges

    Root Cause

    When bulk merging from search (Reports > Expenses), the flow has isOnSearch = true. The PR changed the navigation to always use ROUTES.SEARCH_REPORT for search-based merges.

    The problem occurs when:

    1. User selects workspace expense (target transaction)
    2. Merges with self DM expense (source transaction)
    3. Selects self DM values (including reportID = UNREPORTED_REPORT_ID)

    The code calculates:

    • reportID = self DM report ID (line 74, since mergeTransaction.reportID is UNREPORTED_REPORT_ID)
    • reportIDToDismiss = self DM report ID (line 95)
    • searchReportIDToOpen = targetTransactionThreadReportID ?? reportIDToDismiss (line 97)

    If targetTransactionThreadReportID is undefined or not properly set, the navigation falls back to reportIDToDismiss (self DM report ID), causing navigation to the self DM chat instead of the transaction thread.

    The issue is that the navigation logic does not properly prioritize the transaction thread for bulk merges when the selected reportID is unreported.

  7. 127 remaining items

  8. melvin-bot commented on Oct 9, 2026

    @melvin-bot

    @rojiphil, @mallenexpensify, @MonilBhavsar, @marufsharifi, this Monthly task hasn't been acted upon in 6 weeks; closing.

    If you disagree, feel encouraged to reopen it -- but pick your least important issue to close instead.

  9. removed their assignment
    on Oct 18, 2026
  10. Kabeer099 commented on Oct 29, 2026

    @Kabeer099
  11. melvin-bot commented on Nov 6, 2026

    @melvin-bot

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

  12. melvin-bot commented on Nov 10, 2026

    @melvin-bot

    @rojiphil Still overdue 6 days?! Let's take care of this!

  13. melvin-bot commented on Nov 12, 2026

    @melvin-bot

    @rojiphil Now this issue is 8 days overdue. Are you sure this should be a Daily? Feel free to change it!

  14. mallenexpensify commented on Nov 13, 2026

    @mallenexpensify
    Contributor

    @rojiphil please wrap this up with Melvin, if possible. If not, post in #contributor-plus to ask for help from a C+. Thx

  15. huult commented on Nov 14, 2026

    @huult
    Contributor

    I can help as a C+ if needed.

  16. aimane-chnaif commented on Nov 14, 2026

    @aimane-chnaif
    Contributor
  17. rojiphil commented on Nov 14, 2026

    @rojiphil
    Contributor

    @MelvinBot Please review this issue afresh and the reference PR #96633.
    If there are any pending implementation gaps in the PR, suggest any further needed changes.
    Also, generate indexed test steps to verify the coverage of the fix.

  18. MelvinBot commented on Nov 14, 2026

    @MelvinBot
    Contributor

    Reviewed Fix merge expense transaction thread navigation at 911eb7e. There are still implementation gaps worth addressing in the replacement PR. The reference PR is closed, not merged.

    This was a static code review; the steps below are proposed coverage, not newly executed tests.

    Review findings

    What is the root cause of the remaining problems?

    1. A known thread ID can still bypass offline seeding.
      Confirmation only resolves snapshot context when the thread ID is missing. If the transaction already supplies an ID but its report and parent action are absent from Onyx, navigation retains the ID while the merge action loses it. The thread-seeding branch is then skipped.

    2. Rollback can delete unrelated thread actions.
      The missing-report branch replaces the entire thread-action collection; failure subsequently deletes it wholesale. Existing actions—or an offline comment added after merging—can be removed rather than just undoing the merge’s placeholder.

    3. Moving the workspace expense to self-DM can skip emptied-report cleanup.
      Original workspace-report/preview cleanup sits inside a branch skipped when the deleted source is unreported and self-DM exists. Consequently, the old report and preview remain in optimistic state. This does not establish that the old amount remains visibly rendered.

    Code evidence

    What further changes are needed?

    1. Pass the resolved thread ID explicitly into the merge action. Resolve missing report/action context independently of whether that ID exists.
    2. Preserve existing thread actions; insert/remove only the synthetic placeholder. Ensure rollback preserves independently queued comments and their state.
    3. Separate emptied workspace-report/preview cleanup from source-expense deletion, with corresponding rollback.
    4. Add integration coverage for the confirmation-page-to-action handoff, not only direct action-helper tests.

    The latest offline wrong-amount report remains unverified. The selected amount already reaches the newly created destination action, so another generic amount/sign change is not justified. Reproduce it while recording whether the incorrect value appears in the expense details, thread title, report total, or workspace preview, and which destination was selected.

    Indexed verification steps

    Preparation: Use fresh manual expenses with the same currency but deliberately different amounts: workspace 25, self-DM 60, with distinguishable merchants.

    1. Original bulk flow, online: Create self-DM first, then workspace expense. Open Spend → Expenses → select workspace checkbox → Merge → select self-DM expense → Continue → choose the self-DM values → finish. Verify the merged transaction thread opens, not “Your space,” showing 60.

    2. Individual flow, online: Repeat from the workspace expense’s More → Merge menu. Verify the same destination, amount, and merchant as step 1.

    3. Offline bulk flow: Repeat step 1, disconnecting after loading Spend. Verify populated expense details open without an indefinite skeleton.

    4. Two-checkbox flow: Offline, select both expenses in Spend, then Merge. Choose the self-DM values. Verify the same result as step 3.

    5. Latest reported amount case: Offline, start from a single-expense report in workspace chat. Select the unreported expense’s amount. Run separately with self-DM and workspace destinations. Verify every applicable detail, thread title, card, and report total shows 60, not 25.

    6. Creation-order variation: Repeat steps 3–5 with workspace created first. Verify results do not depend on creation order; the removed expense must not remain selected or reappear as an active duplicate.

    7. Thread-cache variations: Repeat offline with an opened/cached thread and a never-opened thread. Add automated fixtures for an existing thread ID with a missing/partial report, both with and without snapshot report data. Verify the existing ID is reused and fully seeded.

    8. Original-report cleanup: After moving the workspace expense to self-DM, return to workspace chat. Verify its emptied single-expense report/preview is removed rather than left stale.

    9. Split regression: Merge a workspace manual expense with an eligible split expense through Spend. Verify the correct merged thread opens and displays the selected values.

    10. Reconnect and refresh: Reconnect after each offline destination case, let requests finish, then reload. Verify one surviving expense, unchanged selected values, working thread navigation, and no duplicate placeholder cards.

    11. Failure/rollback: In an automated failure fixture, reject the merge after adding an offline comment to the opened thread. Verify original expenses, amounts, reports, and previews are restored without deleting that comment or pre-existing actions.

    12. Shared loading regression: Open ordinary cached chats and expense reports offline. Verify usable content still renders; check actual console output separately for JavaScript errors.


    view run

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.DailyKSv2EngineeringExternalAdded to denote the issue can be worked on by a contributorNot a priorityReviewingHas a PR in review

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions