Repository navigation
Conversation
|
@mananjadhav 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] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 90a428523c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (transactionUnit && rateUnit && transactionUnit === rateUnit) { | ||
| return transactionUnit; | ||
| } | ||
|
|
||
| return rateUnit ?? CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES; |
There was a problem hiding this comment.
Preserve stored transaction unit even when rate differs
The default getRate path is documented to prefer the transaction’s stored distance unit so existing expenses don’t change when policy rates change, but this new guard returns rateUnit whenever it doesn’t match transactionUnit. That means any transaction created in miles will be reinterpreted in kilometers (or vice‑versa) as soon as the current rate unit differs, which can change the displayed distance/amount and merchant text for existing expenses on workspace switches. This undermines the “use transaction unit by default” behavior and should only happen in the explicit useTransactionDistanceUnit: false path.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
@marufsharifi I think for future reference it's best to add a comment response here on why we're not accepting the suggestion.
There was a problem hiding this comment.
@mananjadhav, thanks for the feedback. I understand the intent of the default getRate path. The guard does not override the transaction unit indiscriminately; it only does so when the stored transaction unit conflicts with the currently active mileage rate’s unit. That conflict happens specifically when the user switches to a workspace whose active rate uses a different unit. In that case, keeping the old transaction unit is what causes the bug (unit leakage across workspaces).
So this change doesn’t reinterpret existing expenses “as soon as the current rate unit differs” in general; it only resolves an actual mismatch between the stored transaction unit and the active rate unit. When they match, behavior is unchanged and the transaction unit remains the source of truth. The fallback to rateUnit is therefore targeted to the workspace‑switch scenario causing the issue, not a blanket change of the default behavior.
|
@marufsharifi Please check the AI feedback and the lint failures. |
|
@mananjadhav, thanks for the review. The lint error is not related to our changes. I do not agree with the AI here. |
|
@mananjadhav, pr is ready for your review. thanks |
|
@mananjadhav, kindly bump. thanks. |
|
I am reviewing the PR. |
|
|
||
| function getDistanceUnit(transaction: OnyxEntry<Transaction>, mileageRate: OnyxEntry<MileageRate>): Unit { | ||
| return transaction?.comment?.customUnit?.distanceUnit ?? mileageRate?.unit ?? CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES; | ||
| const transactionUnit = transaction?.comment?.customUnit?.distanceUnit; |
There was a problem hiding this comment.
I think it makes sense to add a test for the same.
There was a problem hiding this comment.
@mananjadhav, just to confirm, do you want me to adda unit test for the getDistanceUnit function?
There was a problem hiding this comment.
@mananjadhav, the test is added. Please take a look. thanks
| const transactionUnit = transaction?.comment?.customUnit?.distanceUnit; | ||
| const rateUnit = mileageRate?.unit; | ||
|
|
||
| if (transactionUnit && rateUnit && transactionUnit === rateUnit) { |
There was a problem hiding this comment.
I think it's unnecessary to check if rateUnit is valid value.
|
@mananjadhav, pr is ready for your review. Please continue reviewing when you get a chance. Thanks |
|
I am testing this PR. |
|
@mananjadhav, kindly bump. thanks. |
|
@marufsharifi Quick bump on the question here. Also, I am trying to build the test case for edit transaction in case the rate unit changes. Is that covered in the current change? |
|
@marufsharifi Can you please resolve the conflicts? |
|
@mananjadhav, conflicts resolved. thanks. |
@mananjadhav |
|
@mananjadhav, quick bump. thanks. |
|
@mananjadhav, quick bump. thanks. |
|
@mananjadhav, kindly bump. thanks. |
Screenshots/VideosAndroid: HybridAppandroid-distance-workspace.movAndroid: mWeb Chromemweb-chrome-distance-workspace.moviOS: HybridAppios-distance-workspace.moviOS: mWeb Safarimweb-safari-distance-workspace.movMacOS: Chrome / Safariweb-distance-workspace.mov |
Reviewer Checklist
|
There was a problem hiding this comment.
Had some issues with my previous checklist comment. I deleted the checklist and added again. Thanks for the patience here @marufsharifi.
|
@danieldoglas, kindly bump. thanks. |
|
@danieldoglas, quick bump. thanks. |
|
@mananjadhav, I think @danieldoglas is ooo, who is responsible for reviewing the pr, since it waiting since last week. thanks. |
|
I've asked to reassign. Meanwhile @marufsharifi please keep the branch synced with main. |
|
@mananjadhav 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] |
mananjadhav
left a comment
There was a problem hiding this comment.
Approving the PR to see if someone else gets assigned.
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #78212 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
|
🚧 @inimaga has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ 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/inimaga in version: 9.3.31-0 🚀
|
|
Deploy Blocker #84195 was identified to be related to this PR. |
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.3.31-12 🚀
|
Explanation of Change
Ensure the distance unit correctly updates from km to miles (and vice versa)
When switching workspaces after selecting a non-default rate.
Fixed Issues
$ #78212
PROPOSAL: #78212 (comment)
Tests
Preconditions:
On User A's side
On User's B side
User B has created his default workspace with distance rates enabled
Steps:
distance & amount.Offline tests
Same as Tests
QA Steps
Same as Tests
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, 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.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
a-n.mp4
Android: mWeb Chrome
a-w.mp4
iOS: Native
i-n.mp4
iOS: mWeb Safari
i-w.mp4
MacOS: Chrome / Safari
Screen.Recording.1404-10-25.at.10.13.25.AM.mp4