Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/libs/actions/IOU/MoneyRequestBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -781,10 +781,7 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR
value: {
pendingAction: null,
pendingFields: clearedPendingFields,
// The routes contains the distance in meters. Clearing the routes ensures we use the distance
// in the correct unit stored under the transaction customUnit once the request is created.
// The route is also not saved in the backend, so we can't rely on it.
routes: null,
// Keep `routes`: the BE never returns it, so it's the only source `ConfirmedRoute`/the preview can draw the map from (GH #90057).
},
},

Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/IOU/TrackExpense.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ function buildOnyxDataForTrackExpense({
value: {
pendingAction: null,
pendingFields: clearedPendingFields,
routes: null,
// Keep `routes`: the BE never returns it, so it's the only source `ConfirmedRoute`/the preview can draw the map from (GH #90057).
},
},
);
Expand Down
15 changes: 4 additions & 11 deletions src/libs/actions/IOU/UpdateMoneyRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1306,22 +1306,16 @@ function getUpdateMoneyRequestParams(params: GetUpdateMoneyRequestParamsType): U
apiParams.attendees = JSON.stringify(apiParams?.attendees);
}

// Clear out the error fields and loading states on success.
// Only clear `routes` when waypoints/rate changed (the server will push a fresh route via Pusher).
// For pure distance edits the route is unchanged, and clearing it would make the map briefly disappear.
// When the caller already supplied a valid optimistic route (waypoint edit with route pre-fetched
// locally), keep it so the receipt thumbnail and ConfirmedRoute don't flicker between success and
// the Pusher route push.
const hasValidOptimisticRoute = !!transactionChanges.routes?.route0?.geometry?.coordinates?.length;
const shouldClearRoutes = (hasWaypointAddressesChanged || hasModifiedDistanceRate) && !hasValidOptimisticRoute;
// Clear out the error fields and loading states on success. Keep `routes`: the BE never returns it,
// so it's the only source `ConfirmedRoute`/the preview can draw the map from while the receipt
// regenerates after a rate/distance edit (GH #90057); a waypoint edit clears + re-fetches it anyway.
successData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
value: {
pendingFields: clearedPendingFields,
isLoading: false,
errorFields: null,
...(shouldClearRoutes && {routes: null}),
},
});

Expand Down Expand Up @@ -1672,15 +1666,14 @@ function getUpdateTrackExpenseParams(
});
}

// Clear out the error fields and loading states on success
// Clear out the error fields and loading states on success. Keep `routes` (see `getUpdateMoneyRequestParams`) — GH #90057.
successData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
value: {
pendingFields: clearedPendingFields,
isLoading: false,
errorFields: null,
routes: null,
},
});

Expand Down
Loading