Skip to content

Commit 2a7d7aa

Browse files
authored
Merge pull request Expensify#90260 from Expensify/aimane-chnaif/fix-90057-distance-rate-placeholder
fixed placeholder image on distance rate change
2 parents 2474173 + ef80e08 commit 2a7d7aa

3 files changed

Lines changed: 6 additions & 16 deletions

File tree

src/libs/actions/IOU/MoneyRequestBuilder.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -781,10 +781,7 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR
781781
value: {
782782
pendingAction: null,
783783
pendingFields: clearedPendingFields,
784-
// The routes contains the distance in meters. Clearing the routes ensures we use the distance
785-
// in the correct unit stored under the transaction customUnit once the request is created.
786-
// The route is also not saved in the backend, so we can't rely on it.
787-
routes: null,
784+
// Keep `routes`: the BE never returns it, so it's the only source `ConfirmedRoute`/the preview can draw the map from (GH #90057).
788785
},
789786
},
790787

src/libs/actions/IOU/TrackExpense.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ function buildOnyxDataForTrackExpense({
478478
value: {
479479
pendingAction: null,
480480
pendingFields: clearedPendingFields,
481-
routes: null,
481+
// Keep `routes`: the BE never returns it, so it's the only source `ConfirmedRoute`/the preview can draw the map from (GH #90057).
482482
},
483483
},
484484
);

src/libs/actions/IOU/UpdateMoneyRequest.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,22 +1306,16 @@ function getUpdateMoneyRequestParams(params: GetUpdateMoneyRequestParamsType): U
13061306
apiParams.attendees = JSON.stringify(apiParams?.attendees);
13071307
}
13081308

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

@@ -1672,15 +1666,14 @@ function getUpdateTrackExpenseParams(
16721666
});
16731667
}
16741668

1675-
// Clear out the error fields and loading states on success
1669+
// Clear out the error fields and loading states on success. Keep `routes` (see `getUpdateMoneyRequestParams`) — GH #90057.
16761670
successData.push({
16771671
onyxMethod: Onyx.METHOD.MERGE,
16781672
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
16791673
value: {
16801674
pendingFields: clearedPendingFields,
16811675
isLoading: false,
16821676
errorFields: null,
1683-
routes: null,
16841677
},
16851678
});
16861679

0 commit comments

Comments
 (0)