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
[$250] Distance - After changing unit, Distance field keeps the new value with old unit #83654
Version Number: 9.3.26-7 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:#82257 Email or phone of affected tester (no customers):sdjoijnsdoinsjoisjio@gmail.com Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Mac 26.2 / Chrome App Component: Money Requests
Action Performed:
Precondition:
Enable Distance rates in workspace settings > More features.
Go to staging.new.expensify.com
Go to workspace chat.
Create a manual distance expense.
Open the expense.
Click More > Split > Save.
Go to workspace settings > Distance rates.
Click Settings > Unit.
Change to another unit.
Open any distance split from Step 5.
Click Amount > click highlighted row.
Click Distance.
Click Save.
Click Distance.
Click Save.
Expected Result:
After saving distance with new unit, Distance field should also save the new unit.
Actual Result:
After saving distance with new unit, Distance field keeps the new value with old unit.
When user reopens Distance and resaves it, the value is converted again and old unit is saved.
👋 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.
Please re-state the problem that we are trying to solve in this issue.
After changing the distance rate unit in workspace settings (e.g., miles → kilometers), editing a split expense's Distance field shows the correctly converted value but with the wrong unit label. When the user saves and reopens the Distance field, the value gets converted again, compounding the error on each save cycle.
What is the root cause of that problem?
The root cause is in getUpdatedTransaction in src/libs/TransactionUtils/index.ts:859-888. When processing a distance change for split edits, it updates comment.customUnit.quantity with the new distance value (which is expressed in the current policy unit) but never updates comment.customUnit.distanceUnit to match.
Here's the specific flow that triggers the bug:
A split is created with 10 mi. The split draft stores quantity=10, distanceUnit='mi'.
The workspace admin changes the distance unit from miles to kilometers.
The user opens the Distance field on the split. IOURequestStepDistanceManual.tsx:112-116 uses useTransactionDistanceUnit: false to get the current policy unit (km), correctly converts 10 mi → 16.09 km for display.
The user saves. setDraftSplitTransaction is called with {distance: 16.09}, which triggers getUpdatedTransaction. At line 862, quantity is set to 16.09. At line 865-866, the policy unit km is fetched correctly for amount calculation. But distanceUnit on the draft is never updated — it remains 'mi'.
The split draft now has quantity=16.09 (in km) but distanceUnit='mi' — a mismatch.
When the user reopens the Distance field, getDistanceInMeters at line 117 reads distanceUnit='mi' from the draft and interprets 16.09 as miles, converting it to ~25,896 meters instead of the correct ~16,090 meters. This is then displayed as ~25.9 km.
Each subsequent save-and-reopen cycle compounds the error.
By contrast, the customUnitRateID change handler at lines 757-773 in the same function does correctly update distanceUnit (line 766) and convert the quantity (lines 769-772). The distance change handler was simply missing the same distanceUnit update.
What changes do you think we should make in order to solve the problem?
In src/libs/TransactionUtils/index.ts, in the distance change handler block (line 859-888), add a line to update distanceUnit to match the current policy unit. Specifically, after line 866 where unit is already available from the policy rate, add:
This ensures the split draft's distanceUnit stays in sync with the unit the quantity value was expressed in, preventing the mismatch that causes the double-conversion bug.
What alternative solutions did you explore? (Optional)
An alternative would be to update distanceUnit in the split-specific save path in IOURequestStepDistanceManual.tsx:169-171 by passing distanceUnit alongside distance in the transactionChanges. However, fixing it in getUpdatedTransaction is more robust since it addresses the root cause at the shared utility level, ensuring any caller that updates distance on a transaction also gets the correct distanceUnit.
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.
👋 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.
Classification: Frontend bug Causing PR: #82257 - "feat: handle the Distance and Rate fields for splits" by @ZhenjaHorbach (High confidence) Related Issues: None
Recommendation: REVERT
This is a new feature that does not exist in production (as confirmed in the issue description: "N/A - new feature, doesn't exist in prod"). The bug fundamentally breaks the distance split editing flow when workspace distance units are changed, causing values to be incorrectly converted on each save cycle. A clean revert is the safest option to unblock the deploy, and the feature can be re-introduced with a proper fix.
PR #82257 was merged on 2026-02-24 and appears in the current StagingDeployCash checklist (#83466). The PR added the ability to edit distance and rate fields on individual splits. MelvinBot automatically assigned this issue to the PR author, and the reproduction steps directly involve the new split distance editing functionality introduced by this PR.
Verification
The bug occurs in split distance expense editing. PR #82257 modified these key files:
All files are in the App repository and directly relate to the reported split distance editing bug.
Root Cause
In src/libs/TransactionUtils/index.ts lines 859-888, the distance change handler updates comment.customUnit.quantity with the new distance value (line 862) and correctly fetches the current policy unit at line 866. However, it never updates comment.customUnit.distanceUnit to match.
This creates a mismatch: the quantity is stored in the new unit (e.g., km) but distanceUnit still reflects the old unit (e.g., mi).
When the user reopens the Distance field, getDistanceInMeters() at line 117 of IOURequestStepDistanceManual reads the mismatched distanceUnit and interprets the quantity as being in the wrong unit, causing incorrect conversion. Each save-reopen cycle compounds the error.
By contrast, the customUnitRateID change handler in the same file (lines 757-773) correctly updates distanceUnit at line 766 and properly converts the quantity when the unit changes (lines 769-772). The distance handler should follow this same pattern but currently does not.
Activity
melvin-bot commentedon Feb 27, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #82257
melvin-bot commentedon Feb 27, 2026
💬 A slack conversation has been started in #expensify-open-source
melvin-bot commentedon Feb 27, 2026
Triggered auto assignment to @heyjennahay (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.github-actions commentedon Feb 27, 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 Feb 27, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
After changing the distance rate unit in workspace settings (e.g., miles → kilometers), editing a split expense's Distance field shows the correctly converted value but with the wrong unit label. When the user saves and reopens the Distance field, the value gets converted again, compounding the error on each save cycle.
What is the root cause of that problem?
The root cause is in
getUpdatedTransactioninsrc/libs/TransactionUtils/index.ts:859-888. When processing adistancechange for split edits, it updatescomment.customUnit.quantitywith the new distance value (which is expressed in the current policy unit) but never updatescomment.customUnit.distanceUnitto match.Here's the specific flow that triggers the bug:
quantity=10, distanceUnit='mi'.IOURequestStepDistanceManual.tsx:112-116usesuseTransactionDistanceUnit: falseto get the current policy unit (km), correctly converts 10 mi → 16.09 km for display.setDraftSplitTransactionis called with{distance: 16.09}, which triggersgetUpdatedTransaction. At line 862,quantityis set to16.09. At line 865-866, the policy unitkmis fetched correctly for amount calculation. ButdistanceUniton the draft is never updated — it remains'mi'.quantity=16.09(in km) butdistanceUnit='mi'— a mismatch.getDistanceInMetersat line 117 readsdistanceUnit='mi'from the draft and interprets16.09as miles, converting it to ~25,896 meters instead of the correct ~16,090 meters. This is then displayed as ~25.9 km.By contrast, the
customUnitRateIDchange handler at lines 757-773 in the same function does correctly updatedistanceUnit(line 766) and convert the quantity (lines 769-772). Thedistancechange handler was simply missing the samedistanceUnitupdate.What changes do you think we should make in order to solve the problem?
In
src/libs/TransactionUtils/index.ts, in thedistancechange handler block (line 859-888), add a line to updatedistanceUnitto match the current policy unit. Specifically, after line 866 whereunitis already available from the policy rate, add:This ensures the split draft's
distanceUnitstays in sync with the unit thequantityvalue was expressed in, preventing the mismatch that causes the double-conversion bug.What alternative solutions did you explore? (Optional)
An alternative would be to update
distanceUnitin the split-specific save path inIOURequestStepDistanceManual.tsx:169-171by passingdistanceUnitalongsidedistancein thetransactionChanges. However, fixing it ingetUpdatedTransactionis more robust since it addresses the root cause at the shared utility level, ensuring any caller that updatesdistanceon a transaction also gets the correctdistanceUnit.Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR, or@MelvinBot <your feedback>to refine this analysis.13 remaining items
melvin-bot commentedon Feb 27, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #82257
melvin-bot commentedon Feb 27, 2026
💬 A slack conversation has been started in #expensify-open-source
github-actions commentedon Feb 27, 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:
OSBotify commentedon Feb 27, 2026
🔍 Investigation Summary
Classification: Frontend bug
Causing PR: #82257 - "feat: handle the Distance and Rate fields for splits" by @ZhenjaHorbach (High confidence)
Related Issues: None
Recommendation: REVERT
This is a new feature that does not exist in production (as confirmed in the issue description: "N/A - new feature, doesn't exist in prod"). The bug fundamentally breaks the distance split editing flow when workspace distance units are changed, causing values to be incorrectly converted on each save cycle. A clean revert is the safest option to unblock the deploy, and the feature can be re-introduced with a proper fix.
Labels: Keeping
DeployBlockerCash(frontend App PR caused the issue, blocks App deploy)📋 Detailed Analysis
Evidence
PR #82257 was merged on 2026-02-24 and appears in the current StagingDeployCash checklist (#83466). The PR added the ability to edit distance and rate fields on individual splits. MelvinBot automatically assigned this issue to the PR author, and the reproduction steps directly involve the new split distance editing functionality introduced by this PR.
Verification
The bug occurs in split distance expense editing. PR #82257 modified these key files:
src/libs/TransactionUtils/index.ts(added distance change handler)src/pages/iou/request/step/IOURequestStepDistanceManual.tsx(split editing logic)src/pages/iou/SplitExpenseEditPage.tsx(split distance/rate UI)src/libs/actions/IOU/Split.ts(split transaction handling)All files are in the App repository and directly relate to the reported split distance editing bug.
Root Cause
In
src/libs/TransactionUtils/index.tslines 859-888, thedistancechange handler updatescomment.customUnit.quantitywith the new distance value (line 862) and correctly fetches the current policy unit at line 866. However, it never updatescomment.customUnit.distanceUnitto match.This creates a mismatch: the quantity is stored in the new unit (e.g., km) but distanceUnit still reflects the old unit (e.g., mi).
When the user reopens the Distance field,
getDistanceInMeters()at line 117 of IOURequestStepDistanceManual reads the mismatcheddistanceUnitand interprets the quantity as being in the wrong unit, causing incorrect conversion. Each save-reopen cycle compounds the error.By contrast, the
customUnitRateIDchange handler in the same file (lines 757-773) correctly updatesdistanceUnitat line 766 and properly converts the quantity when the unit changes (lines 769-772). The distance handler should follow this same pattern but currently does not.lakchote commentedon Feb 27, 2026
Demoting see https://expensify.slack.com/archives/C01GTK53T8Q/p1772178688372119?thread_ts=1772167778.183409&cid=C01GTK53T8Q
melvin-bot commentedon Mar 6, 2026
@suneox, @heyjennahay, @lakchote, @ZhenjaHorbach Still overdue 6 days?! Let's take care of this!
lakchote commentedon Mar 9, 2026
We should use the original transaction, as the source of truth see https://expensify.slack.com/archives/C01GTK53T8Q/p1772215403956329?thread_ts=1772167778.183409&cid=C01GTK53T8Q