You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Distance-Rate with narrower range is not selected over Rate with wider range #93145
Version Number: v9.4.2-0 Reproducible in staging?: Yes Reproducible in production?: N/A - new feature, doesn't exist in prod If this was caught during regression testing, add the test name, ID and link from BrowserStack:#92578 Email or phone of affected tester (no customers):applausetester+ag090626@applause.expensifail.com Issue reported by: Applause Internal Team Bug source: Pull Request QA execution Device used: Windows 11/ Chrome, Samsung S23FE/ Android 16, iPhone 13 Mini/ iOS 26.3 App Component: Money Requests
Action Performed:
Setup: Use an Expensifail account.
Create multiple distance rates on the workspace with different date bounds:
Rate A: "2025 mileage" — $0.50/mile, start: 2025-01-01, end: 2025-12-31
Rate B: "2026 mileage" — $0.60/mile, start: 2026-01-01, end: 2026-12-31
Rate C: "Default rate" — $0.55/mile, no dates (unbounded)
Rate D: $0.65/mile, start: 2026-06-01, end: 2026-06-30
Go to staging.new.expensify.com
Create a distance manual request with a date in June 2026 and manually change the rate to Rate B (2026 mileage)
Start a distance manual request
Enter the distance
Select a date in 2025
Verify that the rate is changed to Rate A (2025 mileage)
Change the date to any in June 2026
Expected Result:
The rate is set to Rate D, as the narrower range overrides the wider range.
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
Identify the pull request that introduced this issue and revert it.
When a date is changed on a distance request, IOURequestStepDate.tsx:129-137 calls getCustomUnitRateID to recompute the rate. That function honors the last selected rate first, and only falls back to the "best eligible (narrowest) rate" if the last selected one is ineligible:
In the repro, manually picking Rate B (2026 mileage) writes it as the last selected rate via setLastSelectedDistanceRate → MoneyRequest.ts:712. When the date is then changed to June 2026, Rate B is still eligible for that date (June 2026 ∈ 2026-01-01…2026-12-31), so the function short-circuits at line 491-492 and returns Rate B — it never reaches getBestEligibleRate, which would have selected the narrower Rate D (2026-06-01…2026-06-30).
This is a precedence conflict between two rules the PR introduced: "last selected rate respected when eligible" (PR Test 5) vs "narrower date range wins" (PR Test 3). The two only collide when the last-selected rate and a narrower rate both cover the chosen date — exactly this scenario.
Why the 2025 step works but June 2026 doesn't
Date → 2025: last-selected Rate B is not eligible for 2025, so the short-circuit is skipped and getBestEligibleRate correctly returns Rate A.
Date → June 2026: last-selected Rate B is eligible, so it short-circuits and wins before the narrower-range tie-break can run.
What changes do you think we should make in order to solve the problem?
Decide which rule wins when a manually-selected rate and a narrower bounded rate both cover the date — this is a product decision the PR author should confirm. The two viable fixes in getCustomUnitRateID:
If "narrower range always wins on date change" is intended (matches the issue's Expected Result): when an expenseDate is provided, only honor the last-selected rate if it equals the best eligible rate — i.e. compute getBestEligibleRate first and prefer it over the last-selected short-circuit. Note this softens PR Test 5 when a narrower rate exists.
If the user's manual choice should be preserved, then the issue's Expected Result is wrong and the test should be updated — but that contradicts the deploy-blocker expectation, so option 1 is the likely correct path.
Recommended: option 1, gated on the date-change flow so it doesn't regress the "respect last selected" behavior for workspaces without overlapping bounded rates.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/93145) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
Activity
applause-bot commentedon Jun 10, 2026
While Applause doesn't embed attachments for this bug, here are the links for quick view:
https://platform.applause.com/services/links/v1/external/d3668b584f2a1f13726aff6d46fca71d87ca4fefb6fd7b8666a68c6ce70a29ab
melvin-bot commentedon Jun 10, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #92578
melvin-bot commentedon Jun 10, 2026
💬 A slack conversation has been started in #expensify-open-source
github-actions commentedon Jun 10, 2026
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
MelvinBot commentedon Jun 10, 2026
Proposal
What is the root cause of that problem?
When a date is changed on a distance request,
IOURequestStepDate.tsx:129-137callsgetCustomUnitRateIDto recompute the rate. That function honors the last selected rate first, and only falls back to the "best eligible (narrowest) rate" if the last selected one is ineligible:DistanceRequestUtils.ts:488-499In the repro, manually picking Rate B (2026 mileage) writes it as the last selected rate via
setLastSelectedDistanceRate→ MoneyRequest.ts:712. When the date is then changed to June 2026, Rate B is still eligible for that date (June 2026 ∈ 2026-01-01…2026-12-31), so the function short-circuits at line 491-492 and returns Rate B — it never reachesgetBestEligibleRate, which would have selected the narrower Rate D (2026-06-01…2026-06-30).This is a precedence conflict between two rules the PR introduced: "last selected rate respected when eligible" (PR Test 5) vs "narrower date range wins" (PR Test 3). The two only collide when the last-selected rate and a narrower rate both cover the chosen date — exactly this scenario.
Why the 2025 step works but June 2026 doesn't
getBestEligibleRatecorrectly returns Rate A.What changes do you think we should make in order to solve the problem?
Decide which rule wins when a manually-selected rate and a narrower bounded rate both cover the date — this is a product decision the PR author should confirm. The two viable fixes in
getCustomUnitRateID:expenseDateis provided, only honor the last-selected rate if it equals the best eligible rate — i.e. computegetBestEligibleRatefirst and prefer it over the last-selected short-circuit. Note this softens PR Test 5 when a narrower rate exists.Recommended: option 1, gated on the date-change flow so it doesn't regress the "respect last selected" behavior for workspaces without overlapping bounded rates.
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/93145)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
rlinoz commentedon Jun 10, 2026
Not a blocker, feature is behind a beta
rlinoz commentedon Jun 10, 2026
Hey @Krishna2323 can you take a look at this one, please?
Krishna2323 commentedon Jun 10, 2026
I'll check in an hour.
rlinoz commentedon Jun 15, 2026
I think this comment should have gone here #93142 (comment)
I think we can close and it is expected behavior, we favor the last user selected rate.