Skip to content

Commit aaa452a

Browse files
committed
Update cloneCustomUnitWithNewIDs comment to reflect dropped cleanup
1 parent 5276766 commit aaa452a

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/libs/PolicyUtils.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,14 @@ function getDefaultDistanceRate(rates: Record<string, Rate> | undefined): Rate |
316316

317317
function cloneCustomUnitWithNewIDs(unit: CustomUnit, newCustomUnitID: string, newDefaultRateID?: string): CustomUnit {
318318
if (newDefaultRateID) {
319-
// The server-side DUPLICATE_POLICY assigns newDefaultRateID to the source's default rate.
320-
// Non-default rates keep their source IDs so they remain visible offline; successData clears
321-
// them after the API succeeds so the server response can repopulate with fresh server IDs
322-
// without leaving duplicates. Iteration order is preserved from the source (default's key
323-
// swapped in place) so getDefaultMileageRate's stable sort still picks the original default
324-
// when other rates have a missing index (which would otherwise tie at CONST.DEFAULT_NUMBER_ID).
319+
// The server-side DUPLICATE_POLICY assigns newDefaultRateID to the source's default rate
320+
// and preserves the source's rate IDs for non-default rates in the duplicated workspace.
321+
// Mirror that here: rebind the default to newDefaultRateID, and keep non-default rates with
322+
// their source IDs so they remain visible offline and merge cleanly with the server response
323+
// (same keys, no optimistic-vs-server duplicates). Iteration order is preserved from the
324+
// source (default's key swapped in place) so getDefaultMileageRate's stable sort still picks
325+
// the original default when other rates have a missing index (which would otherwise tie at
326+
// CONST.DEFAULT_NUMBER_ID).
325327
const defaultRate = getDefaultDistanceRate(unit.rates);
326328
const rates: Record<string, Rate> = {};
327329
for (const rate of Object.values(unit.rates)) {

0 commit comments

Comments
 (0)