Skip to content

Distance - After merging expenses, discarded route is removed, map preview is not shown #103274

Closed as not planned

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: 9.5.4-0
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: #102258
Email or phone of affected tester (no customers): jsndojsnodjdsoij@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 two map distance expenses.
  4. Open the report.
  5. Bulk select both expenses > More > Merge.
  6. Select any distance > Continue.
  7. Click Merge expenses.
  8. Click + > Track distance > Map.
  9. Click Reuse route.

Expected Result:

  • Both routes will appear in route list.
  • Map preview will be shown in route list.

Actual Result:

  • The discarded route is removed in route list.
  • Map preview is not shown in route list.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7279485_1791328888601.12.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Mita Rachim
Bug ID: 7279485

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Oct 7, 2026
  2. applause-bot commented on Oct 7, 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/ad828b0d9ba5ef54ddac5f169e657ba469a5111b2db1e5aa57dd15a746ec347c

  3. melvin-bot commented on Oct 7, 2026

    @melvin-bot

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

  4. melvin-bot commented on Oct 7, 2026

    @melvin-bot

    @Gonals @Pujan92 you have been assigned to this deploy blocker because you reviewed the offending PR: #102258

  5. melvin-bot commented on Oct 7, 2026

    @melvin-bot

    @ShridharGoel you have been assigned to this deploy blocker because you authored the offending PR: #102258

  6. melvin-bot commented on Oct 7, 2026

    @melvin-bot

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

  7. github-actions commented on Oct 7, 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.
  8. quantumchain-core commented on Oct 7, 2026

    @quantumchain-core

    Proposal for #103274

    Version: 9.5.4-0
    Repro: Yes in staging

    Action Performed:

    1. Workspace chat > Create 2 map distance expenses (A and B)
    2. Open report > Bulk select both > More > Merge
    3. Select any distance > Continue > Merge expenses
      • Track distance > Map > Reuse route

    4. Check route list

    Expected: Both routes A and B appear in Reuse route list, map preview shown
    Actual: Discarded route (B) is removed from list, map preview not shown


    Root Cause:

    When merging, MERGE_TRANSACTIONS API deletes the discarded transaction (say transaction B) and its routes / comment.waypoints from Onyx (COLLECTION.TRANSACTION).

    The Reuse route screen (src/pages/iou/request/step/DistanceMapPage / DistanceRequestUtils.ts) builds its list from:

    • allTransactions with transactionType = distance
    • NVP_RECENT_WAYPOINTS / getRecentWaypoints() / getRoutes()

    Because transaction B is deleted optimistically + on server, its route is lost and never added to recentWaypoints. Also map preview fails because routes object is cleared before being saved.

    Similar bug fixed for attendees / categories before - discarded expense data was not preserved.

    Fix:

    In src/libs/actions/IOU.ts -> mergeExpenses() / buildMergeExpensesData():

    Before creating optimisticData that deletes discarded transactions, save their routes to recent waypoints:

    // Inside mergeExpenses, for each discardedTransaction
    const discardedTransactions = allTransactions.filter(t => selectedIDs.includes(t.transactionID) && t.transactionID !== keptTransactionID);
    
    discardedTransactions.forEach((discardedTx) => {
        const waypoints = discardedTx.comment?.waypoints ?? discardedTx.routes?.route0?.waypoints;
        if (waypoints) {
            // Preserve for Reuse Route
            optimisticData.push({
                onyxMethod: Onyx.METHOD.MERGE,
                key: ONYXKEYS.NVP_RECENT_WAYPOINTS,
                value: {
                    [JSON.stringify(waypoints)]: waypoints,
                },
            });
            // Also keep transaction routes in recent routes cache if exists
            // so DistanceMapPage can show map preview
        }
    });
  9. MelvinBot commented on Oct 7, 2026

    @MelvinBot
    Contributor

    Deploy Blocker Analysis

    Recommendation: demote. Do not revert. The first part of this report is expected behavior. The second part is a cosmetic gap in the new Reuse route feature from [Payment due @Pujan92] Add Reuse route to the distance creation flow. The feature is not in production yet, so users lose nothing.

    • Discarded route disappears (expected): merging deletes the discarded expense. The Reuse route list shows only existing map expenses from the server, so one route remains.
    • No map preview (cosmetic): the card falls back to the generic receipt icon when the server returns no usable map image for the kept expense. This looks like the same problem as Map thumbnail in Reuse route list disappears after creating distance with previous route. One fix should cover both.
    Investigation details

    1. Why the discarded route disappears

    2. Why the map preview is missing

    • The thumbnail comes only from the server field receiptSource, which becomes <source>.1024.jpg (ReusableDistanceRoutesUtils.ts:63-72).
    • If receiptSource is empty, or if the image fails to load, the card shows the generic receipt icon (ReuseRouteListItem.tsx:45-68).
    • Likely cause (not confirmed): the merge replaces the kept expense's receipt and route. After that, the server returns an empty or stale map image for the route entry. I could not verify the backend side.

    Possible fixes (none urgent)

    • Backend: return the kept expense's current map image after a merge or route change.
    • App: keep showing the last good thumbnail when a refreshed entry has no image.

    Quick check to locate the problem: after the merge, open the kept expense. If its map receipt renders, the route list's image source is wrong. If it does not render, the merge itself drops the map image. That would also happen in production, so it would not block the deploy.


    Next Steps: Reply with @MelvinBot <your feedback> to refine this analysis.


    view run

  10. quantumchain-core commented on Oct 7, 2026

    @quantumchain-core

    Proposal for #103274 - Distance - After merging expenses, discarded route is removed, map preview is not shown

    Version: 9.5.4-0
    Reproducible: Yes staging
    Bug ID: 7279485

    Action Performed:

    1. Go to staging.new.expensify.com
    2. Go to workspace chat
    3. Create two map distance expenses
    4. Open the report
    5. Bulk select both expenses > More > Merge
    6. Select any distance > Continue
    7. Click Merge expenses
    8. Click + > Track distance > Map
    9. Click Reuse route

    Expected Result:

    • Both routes will appear in route list
    • Map preview will be shown in route list

    Actual Result:

    • The discarded route is removed in route list (Expected per product - deduped per unique route, last 90 days)
    • Map preview is not shown in route list (REAL BUG - receiptSource empty after merge)

    Root Cause Analysis (with Melvin blocker analysis):

    1. Discarded route removed = EXPECTED BEHAVIOR
    • File: src/libs/actions/MergeTransaction.ts:485 uses transactionIDList: [sourceTransactionID] which deletes discarded transaction
    • Reuse list ONYXKEYS.COLLECTION.REUSABLE_DISTANCE_ROUTES = "map expenses last 90 days deduped per unique route" - only kept remains. Product decision, not App bug.
    1. Map preview not shown = ACTUAL BUG (cosmetic)
    • src/pages/iou/request/step/DistanceMapPage.tsx:195-200 calls fetchReusableDistanceRoutes() -> OpenReuseRoutePage -> builds list from REUSABLE_DISTANCE_ROUTES
    • Thumbnail in src/components/ReuseRouteListItem.tsx:45-68 and src/libs/ReusableDistanceRoutesUtils.ts:63-72 uses receiptSource -> ${receiptSource}.1024.jpg as <source>.1024.jpg
    • src/libs/MergeTransactionUtils.ts:854-857 - kept expense takes receipt/waypoints/routes of selected distance, but after merge server returns empty/stale receiptSource, so thumbnail fails and falls back to generic receipt icon.

    Fix:

    App side in src/libs/ReusableDistanceRoutesUtils.ts:

    function getMapImageSource(route: ReusableRoute) {
        // Keep last good thumbnail if new entry has no image
        const baseSource = route.receiptSource || route.lastReceiptSource;
        if (!baseSource) {
            // Fallback: generate preview from routes if available
            return route.routes?.route0 ? getMapPreviewFromRoutes(route.routes) : null;
        }
        return `${baseSource}.1024.jpg`;
    }
  11. JmillsExpensify commented on Oct 7, 2026

    @JmillsExpensify
    Contributor

    Let's demote and resolve the cosmetic issue.

  12. added and removed
    DeployBlockerCashThis issue or pull request should block deployment
    on Oct 7, 2026
  13. ShridharGoel commented on Oct 8, 2026

    @ShridharGoel
    Contributor

    @JmillsExpensify Should this be closed since we are not planning to show deleted routes?

  14. JmillsExpensify commented on Oct 8, 2026

    @JmillsExpensify
    Contributor

    Yes.

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.DailyKSv2Engineering

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions