Display rate name instead of rate value on distance expenses#83393
Display rate name instead of rate value on distance expenses#83393
Conversation
981f29d to
99ee2f8
Compare
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
6f6a2ed to
b1f97ef
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b1f97ef0f4
ℹ️ 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".
b1f97ef to
e17adae
Compare
Show the rate name (e.g., "Default Rate") on all expense display sites instead of the formatted rate value (e.g., "$0.67 / mile"). This prevents rate value changes on the workspace from retroactively altering the displayed rate on historical expenses. Consolidate rate display logic into a single getRateForExpenseDisplay() util that handles rate name display, out-of-policy state, and P2P fallback to "Default rate". Updated all call sites: - MoneyRequestView (expense detail page) - MoneyRequestConfirmationListFooter (expense confirmation page) - SplitExpenseEditPage (split expense editing) Co-authored-by: Neil Marcellini <neil-marcellini@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
72f557c to
a019b86
Compare
Co-authored-by: Cursor <cursoragent@cursor.com>
|
@codex pls review again |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 32fdcb9d43
ℹ️ 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".
Previously, getMerchant() recalculated the merchant string from the current workspace rate for every distance expense, causing rate changes to retroactively alter the merchant displayed on historical expenses. Now it returns the stored modifiedMerchant when available, only falling back to recalculation when no merchant has been saved yet (e.g., during expense creation before the merchant is first set). Added a unit test that verifies the stored merchant is preserved even when the policy rate has changed. Co-authored-by: Cursor <cursoragent@cursor.com>
The distance-specific branch was recalculating the merchant from the live workspace rate on every call. This is unnecessary since the merchant is already set on the transaction when the expense is created. Just return modifiedMerchant or merchant like we do for all other expense types. Co-authored-by: Cursor <cursoragent@cursor.com>
For expenses not tied to a workspace (P2P), there's no rate name to display. Instead of showing the generic "Default rate" string, fall back to the formatted rate value (e.g., "$0.67 / mi") which is more informative. Changed getRateForExpenseDisplay to accept a formattedRateFallback string instead of a translate function, used when there's no rate name or when the rate is out of policy. Made-with: Cursor
getRateForExpenseDisplay now handles calling getRateForDisplay internally for P2P expenses instead of requiring callers to pre-compute the formatted rate. The logic is now: - P2P (no rate name): show the formatted rate value (e.g., "$0.67 / mi") - Workspace out-of-policy: show "Rate out of policy" - Workspace normal: show the rate name Made-with: Cursor
Made-with: Cursor
Please fix conflict |
Resolve Mobile-Expensify submodule conflict by using main's pointer. Made-with: Cursor
Only show "Rate out of policy" for workspace expenses (those with a rate name). P2P expenses don't have named rates, so the out-of-policy concept doesn't apply — they always show the formatted rate value. Made-with: Cursor
This reverts commit 6a8e3be.
The getMerchant simplification removed the only usage of getPolicy, leaving an unused import that fails the ESLint CI check. Made-with: Cursor
The test asserted that P2P expenses with isCustomUnitOutOfPolicy=true should show the formatted rate, but the function intentionally checks out-of-policy first regardless of expense type. Made-with: Cursor
|
@neil-marcellini Could you resolve the conflict? Thanks! |
Combine main's isTrackExpense rate calculation logic with the getRateForExpenseDisplay function from this branch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The getMerchant simplification removed the only call site for this function, leaving it unused and causing an ESLint error. Made-with: Cursor
Resolve DistanceRequestUtils.ts export conflict by keeping getRateForExpenseDisplay from this branch alongside isDistanceAmountWithinLimit and normalizeOdometerText from main. Resolve IOURequestStepDistanceRate.tsx conflict by keeping main's pendingRateID/effectiveRateID logic with the branch's renamed getFormattedRateValue function. Made-with: Cursor
|
🚧 @mollfpr has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/mollfpr in version: 9.3.31-0 🚀
|
|
This PR failing because of the issue #84252 in Offline tests 1.mp4 |
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.3.31-12 🚀
|
Explanation of Change
This PR fixes how the rate field and merchant string are displayed on distance expenses so that workspace rate changes no longer retroactively alter historical expenses.
Workspace distance expenses now show the rate name (e.g., "Default Rate") in the rate field instead of the formatted rate value (e.g., "$0.67 / mile"). The rate name is stable — if a workspace admin updates the rate value, existing expenses keep showing the same rate name they were created with. This brings New Expensify in line with the OldDot UX.
P2P distance expenses (not tied to a workspace) have no named rate, so they continue showing the formatted rate value (e.g., "$0.67 / mile") directly.
Merchant string (
getMerchant): Previously,getMerchant()recalculated the merchant string (e.g., "10 mi @ $0.67 / mi") from the live workspace rate on every call for distance expenses. This was added in PR #59063 to $ #58612 but caused workspace rate changes to retroactively alter the merchant on all historical expenses. Since the merchant is already correctly set at creation time (viagetDistanceMerchantinupdateWaypointsandgetUpdatedTransaction), the recalculation was unnecessary.getMerchantis now a simple one-liner that returns the storedmodifiedMerchantormerchantfield, same as for all other expense types.Changes:
DistanceRequestUtils.ts: AddedgetRateForExpenseDisplay()— for P2P expenses (no rate name) it callsgetRateForDisplayinternally and returns the formatted rate value; for workspace expenses it returns the rate name; for out-of-policy workspace rates it returns "Rate out of policy"MoneyRequestView.tsx: UsesgetRateForExpenseDisplayinstead ofgetRateForDisplaySplitExpenseEditPage.tsx: Same change as MoneyRequestViewMoneyRequestConfirmationListFooter.tsx: UsesgetRateForExpenseDisplaywithisCustomUnitOutOfPolicy=falsesince a rate violation is not applicable during expense creation/edit confirmationMoneyRequestConfirmationList.tsx: Passes the newdistanceRateNameprop to the footerTransactionUtils.ts(getMerchant): Simplified to always return the stored merchant from the transactiongetRateForExpenseDisplayandgetMerchantFixed Issues
$ #82123
Tests
Workspace rate change
P2P
Test workspace rate change
2026-02-25_13-25-42.mp4
P2P
2026-02-25_13-21-47.mp4
Workspace single expense report view
2026-02-25_13-22-46.mp4
Offline tests
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand 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
The changes should be platform independent. Please see the test videos on Mac Chrome above.