fix: maintain tax assign when tax code changes#47327
Conversation
|
@rushatgabhane Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-08-27.at.17.56.12.movAndroid: mWeb ChromeiOS: NativeScreen.Recording.2024-08-27.at.17.53.13.moviOS: mWeb SafariScreen.Recording.2024-08-27.at.17.54.14.movMacOS: Chrome / SafariScreen.Recording.2024-08-27.at.17.51.42.mov |
| const customUnits = Object.values(policy?.customUnits ?? {}); | ||
| const optimisticCustomUnit = { | ||
| customUnits: { | ||
| ...customUnits.reduce((units, customUnit) => { |
There was a problem hiding this comment.
Maybe I'm misunderstanding but wouldn't this be better as a map instead of a reduce? Same with the rates.reduce below
There was a problem hiding this comment.
As far as I know, we can't add properties to an object using map, so I need to use reduce here.
There was a problem hiding this comment.
customUnits is an array though right? Could do something here like
customUnits: customUnits.map((customUnit) => {
let newUnit = customUnit;
// modify rates
return newUnit
})Seems a little cleaner? And could use a forEach for the rates object?
what do you think @rushatgabhane
There was a problem hiding this comment.
But since customUnits in optimistic data is of type Record<string, any>, after this we will have to either do an Array.reduce or Object.assign to the updated customUnits anyway.
There was a problem hiding this comment.
oh yeah, fair. Okay then I think this works for me! Thank you for the explanation, that was helpful!
| if (customUnit.rates[rateID].attributes?.taxRateExternalID === oldTaxCode) { | ||
| // eslint-disable-next-line no-param-reassign | ||
| rates[rateID] = { | ||
| attributes: { |
There was a problem hiding this comment.
also do we need to spread the old rate here? to make sure we don't remove everything but attributes?
There was a problem hiding this comment.
This is a merge call, so I think we don't need to include everything inside.
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/dangrous in version: 9.0.27-0 🚀
|
|
🚀 Deployed to production by https://github.com/roryabraham in version: 9.0.27-1 🚀
|

Details
Fixed Issues
$ #45861
PROPOSAL: #45861 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.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
Screen.Recording.2024-08-13.at.23.27.14.mov
Android: mWeb Chrome
Screen.Recording.2024-08-13.at.23.19.07.mov
iOS: Native
Screen.Recording.2024-08-13.at.23.50.25.mov
iOS: mWeb Safari
Screen.Recording.2024-08-13.at.23.47.52.mov
MacOS: Chrome / Safari
Screen.Recording.2024-08-13.at.20.28.04.mov
MacOS: Desktop
Screen.Recording.2024-08-13.at.23.56.25.mov