Skip to content

Commit 43f640b

Browse files
committed
Tighten cloneCustomUnitWithNewIDs comment
1 parent aaa452a commit 43f640b

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

src/libs/PolicyUtils.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,10 @@ 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-
// 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).
319+
// Mirror DUPLICATE_POLICY: rebind the source default to newDefaultRateID, keep other rates
320+
// under their source IDs (the server preserves them). Preserve source iteration order so
321+
// getDefaultMileageRate's stable sort still picks the original default when rates tie on
322+
// index (e.g. a rate with no index falls back to CONST.DEFAULT_NUMBER_ID).
327323
const defaultRate = getDefaultDistanceRate(unit.rates);
328324
const rates: Record<string, Rate> = {};
329325
for (const rate of Object.values(unit.rates)) {

0 commit comments

Comments
 (0)