Feat - [Unreported] Add distance rate to the distance expenses tracked in selfDM#84136
Feat - [Unreported] Add distance rate to the distance expenses tracked in selfDM#84136FitseTLT wants to merge 12 commits intoExpensify:mainfrom
Conversation
…FitseTLT/feat-apply-policyForMovingExpenses-for-rate-field-for-track-distance-expenses""
|
@parasharrajat 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: ad2443ed89
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const hasPendingWaypoints = 'waypoints' in transactionChanges; | ||
| const hasModifiedDistanceRate = 'customUnitRateID' in transactionChanges; | ||
| if (transaction && updatedTransaction && (hasPendingWaypoints || hasModifiedDistanceRate)) { | ||
| if (transaction && updatedTransaction && hasPendingWaypoints) { |
There was a problem hiding this comment.
Clear draft when persisting distance-rate changes
By dropping hasModifiedDistanceRate from this cleanup condition, successful track-expense rate edits no longer remove TRANSACTION_DRAFT entries. That leaves stale draft customUnitRateID/distance-unit data around, and later submit/share/categorize flows can read those drafts (via shouldUseTransactionDraft) instead of the persisted transaction, causing users to move or submit expenses with the wrong rate data.
Useful? React with 👍 / 👎.
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@parasharrajat can you review today? |
|
Yes in testing |
trjExpensify
left a comment
There was a problem hiding this comment.
Core PR for a WN project. 👍
|
@parasharrajat update please? |
Screenshots10.03.2026_18.09.17_REC.mp410.03.2026_16.34.04_REC.mp410.03.2026_17.20.57_REC.mp410.03.2026_17.24.34_REC.mp410.03.2026_17.27.36_REC.mp4 |
This comment was marked as outdated.
This comment was marked as outdated.
|
Ignore the above bug. I had 2 non-default workspaces, so in that case, it makes sense that the unit is based on P2p |
|
How should we handle this case? @cristipaval @FitseTLT Here, the tracked expense has a km unit when it was created. Then we are submitting that to a workspace with miles. 10.03.2026_17.16.36_REC.mp4The same thing happens when editing the same tracked expense. 10.03.2026_17.18.57_REC.mp4 |
|
Tested all reported bugs and they are looking good. |
|
Yeah, nice catch @parasharrajat. What should be the unit @cristipaval in this case, km or mi? After it is submitted, I see that the BE chooses the mi unit. |
|
Hmm.. this is a good one. It works consistently with the other fields: we preserve the values set on the tracked expense fields and display the options from the default workspace when editing, or from the applicable workspace when submitting. @trjExpensify, what do you think from a product perspective? Does this make sense? |
What does this mean? The backend change the unit silently after creation? If so, why wouldn't we do that for them to confirm on the confirmation page after they picked the workspace in this case? 🤔 |
|
@trjExpensify thanks for looking into it. Yes, from the user perspective I think it's best to convert in the confirm page 👍 |
|
So while we are submitting to someone, we change the unit based on target workspace. Is that correct? @cristipaval cc: @FitseTLT |
|
Here is how I understand the confusion. A track expense has distance(let say 4mi), rate, amount. The rate was the default rate of policyForMovingExpense with unit mi.
2026-03-11.16-05-27.mp4It is a bit confusing scenario I need guidance on the expected behavior it is not only a matter of unit. What do we make consistent the distance or amount? cc @trjExpensify @cristipaval |
The problem is the rate is valid as the transaction rate/customUnitRateID already exists in the policy but when we change a unit of a workspace the rates with the same value (numerical value) will have their distance unit changed(this behavior also applies for currency change) So now we will have a different rates on the transaction vs on the workspace. |
Ofcourse we can know @trjExpensify I want to get a direction into what to implement. Note that rate basically includes unit, currency and numerical value. So let's say a track expense was created with an old value (interms of any of three info I mentioned) when we submit it we should show rate no longer valid if the rate is changed. cc @cristipaval Pls tell me the expected behavior and let's finish this thing. |
|
@FitseTLT, I chatted with @trjExpensify, and we want the following logic when the user lands on the confirmation page:
|
@cristipaval @trjExpensify If you are judging rate equality via
This also doesn't look logical behavior to me. If the track was 2mi then the unit changed to km, current behavior is shows in mi in confirm page but when you open the distance it displays it converting it to |
Ah, I think I arrived at a different conclusion on this one. I think the error should be shown on the rate field, as the distance rate in use (say |
Hmmmm. This rate out of policy case will be a bit odd compared to the existing cases. Because on the rate selection page the current transaction rate (which is identified by customUnitRateID) will appear as selected as the rate already exists in the workspace only the unit is changed. And @cristipaval changing the selection logic (to be based also on the unit etc..) will be an unfavorable specialized workaround solution (Let me know your opinion from implementation perspective) So why don't we just auto update the rate to the new workspace value/unit when a track expense is submitted? Note. BTW this problem already exist on main. If you change the unit of a rate then already created transactions will have an old rate unit and it will only change to the new unit if you reselect the rate. The new issue linked to this pr is that we are moving a track expense into a workspace space. |
|
@cristipaval on the ^ |
|
Bump @cristipaval on this. |
|
@FitseTLT @parasharrajat, what I understand is that right now, everything is covered, except for the following scenario:
What we are discussing here is what to show on the confirmation page, correct? I think @trjExpensify was saying here that we could detect whether the amount was calculated with the expense rate using the old unit and show a violation in the rate field, as in Classic. Then, when the user clicks on the Rate field to fix the violation, show the page with the updated workspace rates, and no rate selected by default. So the user can only pick a rate with the updated unit. Once the user picks the rate, we convert the distance to the new unit and update the amount accordingly. @trjExpensify, do I get this right? |








Explanation of Change
Fixed Issues
$ #72230
$ #84010
$ #84013
$ #84006
$ #83964
$ #83955
$ #83990
PROPOSAL:
Tests
I) User with no group workspace
Creation flow
Edit flow
II) User with a group workspace set as the default workspace
III) User with multiple group workspaces that have the personal policy set as the default one
NOTE: To have such a user, you have to go to OldDot and make the personal policy the default workspace from there
Creation flow
Edit flow
Precondition:
Workspace distance unit must be different from personal distance unit.
Precondition:
Enable distance rates.
Change distance unit to Kilometers.
Precondition:
Enable Taxes and Distance rates.
Add two tax rates - 5% and 10 %.
Add a new distance rates - 1.00 / mile.
Enable Track tax in Distance rates settings.
Assign 5% tax rate to 0.725 / mile (default rate) with any tax reclaimable amount.
Assign 10% tax rate to 1.00 / mile with any tax reclaimable amount.
tax no longer validerror will not show and the expense can be created without issue.Precondition:
Enable Taxes and Distance rates.
Add two tax rates - 5% and 10 %.
Add two distance rates - 1.00 / mile and 2.00 / mile.
Enable Track tax in Distance rates settings.
Assign 5% tax rate to 1.00 / mile with any tax reclaimable amount.
Assign 10% tax rate to 2.00 / mile with any tax reclaimable amount.
Precondition:
Workspace has at least two distance rates.
Precondition:
Disable Submissions in Workflows settings.
Offline tests
Same as above
QA Steps
Same as above
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel so 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
2025-12-06.00-56-10.mp4
Android: mWeb Chrome
2025-12-03.17-53-59.mp4
iOS: Native
2025-12-03.19-40-55.mp4
iOS: mWeb Safari
2025-12-03.17-52-46.mp4
MacOS: Chrome / Safari
2025-12-03.17-52-02.mp4
2026-03-05.22-39-48.mp4
2026-03-05.22-31-40.mp4