From 333fa586b82233a68e19f56094299365e8188f5c Mon Sep 17 00:00:00 2001 From: Mukher Date: Mon, 11 May 2026 22:27:35 +0500 Subject: [PATCH] fixed placeholder image on distance rate change --- src/libs/actions/IOU/MoneyRequestBuilder.ts | 5 +---- src/libs/actions/IOU/TrackExpense.ts | 2 +- src/libs/actions/IOU/UpdateMoneyRequest.ts | 15 ++++----------- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/libs/actions/IOU/MoneyRequestBuilder.ts b/src/libs/actions/IOU/MoneyRequestBuilder.ts index e656b45cb455..6661bb869eaf 100644 --- a/src/libs/actions/IOU/MoneyRequestBuilder.ts +++ b/src/libs/actions/IOU/MoneyRequestBuilder.ts @@ -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). }, }, diff --git a/src/libs/actions/IOU/TrackExpense.ts b/src/libs/actions/IOU/TrackExpense.ts index 27fd9186defd..db37183ba741 100644 --- a/src/libs/actions/IOU/TrackExpense.ts +++ b/src/libs/actions/IOU/TrackExpense.ts @@ -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). }, }, ); diff --git a/src/libs/actions/IOU/UpdateMoneyRequest.ts b/src/libs/actions/IOU/UpdateMoneyRequest.ts index 811dac6949a9..eda6412103d8 100644 --- a/src/libs/actions/IOU/UpdateMoneyRequest.ts +++ b/src/libs/actions/IOU/UpdateMoneyRequest.ts @@ -1306,14 +1306,9 @@ 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}`, @@ -1321,7 +1316,6 @@ function getUpdateMoneyRequestParams(params: GetUpdateMoneyRequestParamsType): U pendingFields: clearedPendingFields, isLoading: false, errorFields: null, - ...(shouldClearRoutes && {routes: null}), }, }); @@ -1672,7 +1666,7 @@ 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}`, @@ -1680,7 +1674,6 @@ function getUpdateTrackExpenseParams( pendingFields: clearedPendingFields, isLoading: false, errorFields: null, - routes: null, }, });