Fix duplicate distance rates after copying workspace settings - #99678
Draft
neil-marcellini wants to merge 1 commit into
Draft
Fix duplicate distance rates after copying workspace settings#99678neil-marcellini wants to merge 1 commit into
neil-marcellini wants to merge 1 commit into
Conversation
Copy settings wrote the source's rates under the source's own customUnitRateIDs, while Auth persists them under the target's existing rate IDs (matched by name) or freshly minted ones. The server push is an Onyx merge keyed by rate ID, so the optimistic entries survived alongside it and every copied rate rendered twice. The optimistic patch now reuses the target's rate ID whenever a rate of the same name exists there, and leaves out rates - and whole units - the target doesn't have, since only Auth can know the IDs those will land under.
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation of Change
(Neil's AI agent)
Copying distance rates (or per diem rates) between workspaces made every copied rate render twice.
The optimistic patch wrote the source unit's rates verbatim, so they landed keyed by the source's
customUnitRateIDs. Auth'sCopyPolicySettingspersists those rates under the target's existing rate IDs where a rate of the same name is already there, and under freshly minted IDs otherwise, then pushescustomUnitsto Onyx as a merge keyed by rate ID. Nothing removed the optimistic entries, so the client ended up holding both sets. SinceOpenAppalso sends policies as a collection merge, the orphaned rates stuck around across reloads.This change makes the optimistic patch mirror what Auth actually persists:
As a side effect the target's own rates that the copy replaces now disappear optimistically instead of lingering, which also matches the backend outcome.
Not covered here: other admins viewing the same target policy still keep rates that the copy removed, because the Auth merge doesn't null out the pre-copy rate IDs (the way it already does for coding rules). That's a backend fix and I'd raise it separately if we want it.
Fixed Issues
$ #99285
PROPOSAL:
Tests
(Neil's AI agent)
Offline tests
(Neil's AI agent)
Copy settings requires a round trip to the server, so it can't complete offline.
QA Steps
(Neil's AI agent)
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari