You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$250] Distance field shows old distance, but waypoints are updated when split is edited offline #83504
Version Number: 9.3.26-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:#82257 Email or phone of affected tester (no customers):sdjoisnjdosnjdosjoi@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:
Go to staging.new.expensify.com
Go to workspace chat.
Create a map distance expense.
Open the expense.
Click More > Split > Save.
Open any split.
Go offline.
Click Amount.
Click on the highlighted row.
Click Distance.
Add one more stop with any waypoint from the recent destination list.
Click Save > Save.
Go online.
Click Distance field.
Expected Result:
Distance field will show the new distance.
Actual Result:
Distance field shows the old distance, but waypoints are updated.
👋 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:
Identify the pull request that introduced this issue and revert it.
Classification: Frontend bug Causing PR: #82257 - "feat: handle the Distance and Rate fields for splits" by @ZhenjaHorbach (High confidence) Related Issues: None identified
Recommendation: REVERT
PR #82257 introduced distance and rate field handling for split expenses but appears to have an issue with offline-to-online synchronization. When a split is edited offline with new waypoints and then goes online, the route/distance recalculation does not properly update the displayed distance field, even though the waypoints are correctly updated.
Labels: No label changes needed. This is a frontend bug, so DeployBlockerCash should remain.
📋 Detailed Analysis
Evidence
PR #82257 was merged on 2026-02-24 and is included in version 9.3.26-0 (listed in the StagingDeployCash issue). The PR introduced:
New SPLIT_DRAFT transaction state for handling split expense drafts
New API command GetRouteForSplitDraft for fetching routes for split drafts
Changes to how waypoints are updated for split transactions
Modified useFetchRoute hook to handle split draft transactions
The issue reproduction steps directly match the new functionality added in this PR:
Creating a map distance expense and splitting it
Editing a split offline
Adding waypoints from recent destinations
Going online and observing the distance field
Verification
The PR modifies these key files related to the bug:
src/libs/actions/Transaction.ts - Added SPLIT_DRAFT state handling in getRoute() and updateWaypoints()
src/pages/iou/request/step/IOURequestStepDistanceMap.tsx - Modified to use splitDraftTransaction when editing splits
src/libs/actions/IOU/Split.ts - Extensive changes to handle distance splits
Root Cause
When editing a split expense offline:
Waypoints are saved to SPLIT_TRANSACTION_DRAFT collection correctly
When going online, useFetchRoute triggers a route fetch using GetRouteForSplitDraft API command
The route is fetched and the distance is calculated by the backend
However, the distance displayed in the UI is not properly updated from the fetched route
The issue appears to be in how the split draft transaction merges the fetched route data back into the displayed transaction. The waypoints are correctly shown (they are saved optimistically), but the distance field (which depends on the route calculation) shows the old value.
This is likely because:
The route response updates SPLIT_TRANSACTION_DRAFT but not the main transaction
Or the distance field is reading from the wrong transaction object
Or there is a race condition where the old distance is being displayed before the route fetch completes
Please re-state the problem that we are trying to solve in this issue.
When a user edits a split distance expense offline by modifying waypoints (e.g., adding a stop), then goes back online and views the distance field, it displays the old distance rather than reflecting the updated waypoints. The waypoints themselves are correctly updated, but the distance value is stale.
What is the root cause of that problem?
The root cause is that comment.customUnit.quantity (the stored distance value) is never cleared on the main split draft when waypoints change during the split distance edit flow.
Here's the exact chain of events:
When the user edits waypoints on a split, saveWaypoint() (Transaction.ts:143-170) correctly clears routes.route0.distance, routes.route0.geometry.coordinates, and comment.customUnit.quantity — but only on the temporary distance edit draft (SPLIT_TRANSACTION_DRAFT + OPTIMISTIC_DISTANCE_SPLIT_TRANSACTION_ID, i.e., key '2').
When the user presses Save on the distance page, submitWaypoints in IOURequestStepDistance.tsx:442-448 calls setDraftSplitTransaction() which propagates changes back to the main split draft (SPLIT_TRANSACTION_DRAFT + OPTIMISTIC_TRANSACTION_ID, key '1').
Inside setDraftSplitTransaction (Split.ts:1803-1811), getUpdatedTransaction() deep-clones the main draft (key '1') and applies the waypoint changes. The deep clone preserves the original comment.customUnit.quantity (the old distance value) because getUpdatedTransaction (TransactionUtils/index.ts:713-751) never clears this field when processing waypoint changes.
Meanwhile, useFetchRoute (useFetchRoute.ts:31-33) cannot recalculate the route because it has an isOffline guard that skips getRoute() entirely when offline. Route fetching uses API.read() which is not queued for offline replay.
When getDistanceInMeters() (getDistanceInMeters.ts:7-18) runs to display the distance, it checks routes.route0.distance first (null — cleared), then falls back to comment.customUnit.quantity — which still contains the old distance value, causing the stale display.
This also affects updateSplitExpenseField (Split.ts:2293-2332), which reads the same stale customUnit.quantity and sends the old distance/amount to the server when the split is finalized.
What changes do you think we should make in order to solve the problem?
In getUpdatedTransaction() in TransactionUtils/index.ts, inside the waypoints change block (line 713+), when waypoints have changed but no route coordinates are available (the "pending from BE" branch at lines 721-726), also clear comment.customUnit.quantity:
// Inside the `if (!transactionChanges.routes?.route0?.geometry?.coordinates)` block:
updatedTransaction.amount = CONST.IOU.DEFAULT_AMOUNT;
updatedTransaction.modifiedAmount = CONST.IOU.DEFAULT_AMOUNT;
updatedTransaction.modifiedMerchant = translateLocal('iou.fieldPending');
// ADD: Clear stale distance so getDistanceInMeters doesn't fall back to old value
lodashSet(updatedTransaction, 'comment.customUnit.quantity', null);
This ensures that when waypoints change without a recalculated route (the offline case), the stale distance quantity is cleared. getDistanceInMeters will then return 0 instead of the old value, and the UI will correctly show the distance as pending until the route is recalculated by the backend when the queued API.write command fires upon reconnection.
This fix is safe for non-split transactions as well, since in that case the amount is already set to 0 and modifiedMerchant is set to "Pending..." — the stale quantity was just never read because non-split edits use API.write(UPDATE_MONEY_REQUEST_DISTANCE) which queues for offline replay and the backend recalculates.
What alternative solutions did you explore? (Optional)
Clear quantity in setDraftSplitTransaction specifically: Could add lodashSet(updatedTransaction, 'comment.customUnit.quantity', null) directly in setDraftSplitTransaction before the Onyx merge. This is more targeted but only fixes the split path — the underlying issue in getUpdatedTransaction would remain for any future callers.
Include customUnit.quantity: null in transactionChanges: Modify IOURequestStepDistance.tsx:446 to pass customUnit: {quantity: null} in the transactionChanges alongside waypoints and routes. This shifts the responsibility to the caller rather than fixing the generic utility.
Add a reconnection handler: Register a listener that triggers getRoute() for split drafts with pending routes when connectivity is restored. This is more complex and doesn't address the stale display issue — the distance would still show the old value until the route is recalculated.
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.
Activity
melvin-bot commentedon Feb 25, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #82257
melvin-bot commentedon Feb 25, 2026
💬 A slack conversation has been started in #expensify-open-source
melvin-bot commentedon Feb 25, 2026
Triggered auto assignment to @trjExpensify (
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.github-actions commentedon Feb 25, 2026
👋 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:
OSBotify commentedon Feb 25, 2026
🔍 Investigation Summary
Classification: Frontend bug
Causing PR: #82257 - "feat: handle the Distance and Rate fields for splits" by @ZhenjaHorbach (High confidence)
Related Issues: None identified
Recommendation: REVERT
PR #82257 introduced distance and rate field handling for split expenses but appears to have an issue with offline-to-online synchronization. When a split is edited offline with new waypoints and then goes online, the route/distance recalculation does not properly update the displayed distance field, even though the waypoints are correctly updated.
Labels: No label changes needed. This is a frontend bug, so
DeployBlockerCashshould remain.📋 Detailed Analysis
Evidence
PR #82257 was merged on 2026-02-24 and is included in version 9.3.26-0 (listed in the StagingDeployCash issue). The PR introduced:
SPLIT_DRAFTtransaction state for handling split expense draftsGetRouteForSplitDraftfor fetching routes for split draftsuseFetchRoutehook to handle split draft transactionsThe issue reproduction steps directly match the new functionality added in this PR:
Verification
The PR modifies these key files related to the bug:
src/libs/actions/Transaction.ts- AddedSPLIT_DRAFTstate handling ingetRoute()andupdateWaypoints()src/pages/iou/request/step/IOURequestStepDistanceMap.tsx- Modified to usesplitDraftTransactionwhen editing splitssrc/pages/iou/request/step/IOURequestStepDistance.tsx- Added split draft transaction handlingsrc/hooks/useFetchRoute.ts- Already supportstransactionStateparametersrc/libs/actions/IOU/Split.ts- Extensive changes to handle distance splitsRoot Cause
When editing a split expense offline:
SPLIT_TRANSACTION_DRAFTcollection correctlyuseFetchRoutetriggers a route fetch usingGetRouteForSplitDraftAPI commandThe issue appears to be in how the split draft transaction merges the fetched route data back into the displayed transaction. The waypoints are correctly shown (they are saved optimistically), but the distance field (which depends on the route calculation) shows the old value.
This is likely because:
SPLIT_TRANSACTION_DRAFTbut not the main transactionMelvinBot commentedon Feb 25, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user edits a split distance expense offline by modifying waypoints (e.g., adding a stop), then goes back online and views the distance field, it displays the old distance rather than reflecting the updated waypoints. The waypoints themselves are correctly updated, but the distance value is stale.
What is the root cause of that problem?
The root cause is that
comment.customUnit.quantity(the stored distance value) is never cleared on the main split draft when waypoints change during the split distance edit flow.Here's the exact chain of events:
When the user edits waypoints on a split,
saveWaypoint()(Transaction.ts:143-170) correctly clearsroutes.route0.distance,routes.route0.geometry.coordinates, andcomment.customUnit.quantity— but only on the temporary distance edit draft (SPLIT_TRANSACTION_DRAFT+OPTIMISTIC_DISTANCE_SPLIT_TRANSACTION_ID, i.e., key'2').When the user presses Save on the distance page,
submitWaypointsin IOURequestStepDistance.tsx:442-448 callssetDraftSplitTransaction()which propagates changes back to the main split draft (SPLIT_TRANSACTION_DRAFT+OPTIMISTIC_TRANSACTION_ID, key'1').Inside
setDraftSplitTransaction(Split.ts:1803-1811),getUpdatedTransaction()deep-clones the main draft (key'1') and applies the waypoint changes. The deep clone preserves the originalcomment.customUnit.quantity(the old distance value) becausegetUpdatedTransaction(TransactionUtils/index.ts:713-751) never clears this field when processing waypoint changes.Meanwhile,
useFetchRoute(useFetchRoute.ts:31-33) cannot recalculate the route because it has anisOfflineguard that skipsgetRoute()entirely when offline. Route fetching usesAPI.read()which is not queued for offline replay.When
getDistanceInMeters()(getDistanceInMeters.ts:7-18) runs to display the distance, it checksroutes.route0.distancefirst (null — cleared), then falls back tocomment.customUnit.quantity— which still contains the old distance value, causing the stale display.This also affects
updateSplitExpenseField(Split.ts:2293-2332), which reads the same stalecustomUnit.quantityand sends the old distance/amount to the server when the split is finalized.What changes do you think we should make in order to solve the problem?
In
getUpdatedTransaction()inTransactionUtils/index.ts, inside the waypoints change block (line 713+), when waypoints have changed but no route coordinates are available (the "pending from BE" branch at lines 721-726), also clearcomment.customUnit.quantity:This ensures that when waypoints change without a recalculated route (the offline case), the stale distance quantity is cleared.
getDistanceInMeterswill then return0instead of the old value, and the UI will correctly show the distance as pending until the route is recalculated by the backend when the queuedAPI.writecommand fires upon reconnection.This fix is safe for non-split transactions as well, since in that case the amount is already set to 0 and
modifiedMerchantis set to "Pending..." — the stalequantitywas just never read because non-split edits useAPI.write(UPDATE_MONEY_REQUEST_DISTANCE)which queues for offline replay and the backend recalculates.What alternative solutions did you explore? (Optional)
Clear quantity in
setDraftSplitTransactionspecifically: Could addlodashSet(updatedTransaction, 'comment.customUnit.quantity', null)directly insetDraftSplitTransactionbefore the Onyx merge. This is more targeted but only fixes the split path — the underlying issue ingetUpdatedTransactionwould remain for any future callers.Include
customUnit.quantity: nullin transactionChanges: ModifyIOURequestStepDistance.tsx:446to passcustomUnit: {quantity: null}in the transactionChanges alongside waypoints and routes. This shifts the responsibility to the caller rather than fixing the generic utility.Add a reconnection handler: Register a listener that triggers
getRoute()for split drafts with pending routes when connectivity is restored. This is more complex and doesn't address the stale display issue — the distance would still show the old value until the route is recalculated.Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR, or@MelvinBot <your feedback>to refine this analysis.5 remaining items
melvin-bot commentedon Feb 25, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022026795641307665315
suneox commentedon Feb 26, 2026
This issue requires both FE and BE handling, as the BE response is the same after clearing the cache.
83504.1.mp4
puneetlath commentedon Feb 26, 2026
Demoting as BE issue. cc @lakchote
lakchote commentedon Feb 27, 2026
EDIT: see #83504 (comment)
This is not a BE issue @puneetlath @suneox. It's a frontend issue cc @ZhenjaHorbach
After going back offline,
UpdateSplitTransactionis called with new waypoints but with old distance/quantity.BE persists what the FE sends, so it's expected that clearing the cache doesn't change anything.
Video:
Screen.Recording.2026-02-27.at.08.19.18.mp4
ZhenjaHorbach commentedon Feb 27, 2026
But how are we planning to calculate it offline?
If the distance between waypoints we can get only online?
lakchote commentedon Feb 27, 2026
We can fix it in the backend at the API layer see https://expensify.slack.com/archives/C01GTK53T8Q/p1772181128663359?thread_ts=1772059958.582579&cid=C01GTK53T8Q
lakchote commentedon Mar 19, 2026
Issue not repro:
Screen.Recording.2026-03-19.at.09.08.47.mp4