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 is saved with new value and old unit after changing rate with different unit #83652
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):shdsubhiudhbuidshs@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:
Distance rates are enabled.
Workspace has at least two distance rates.
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 Rate.
Select another rate.
→ Distance field is converted to the correct value and unit.
Click Save > Save.
Click Distance field on the transaction thread.
Expected Result:
Distance field will show the correct value and unit in Step 12.
Actual Result:
The distance field shows the new value with old unit.
Distance editor further converts the value to the new unit.
👋 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 splitting a distance expense and then changing the workspace's distance unit (e.g., mi → km), editing a split item's rate causes the distance value to be correctly converted but the old unit label to persist. For example, changing from a miles rate to a km rate converts 10 mi to 16.09, but saves it as 16.09 mi instead of 16.09 km. Opening the distance editor then further converts the already-converted value, producing a double-conversion (e.g., 25.90 km).
What is the root cause of that problem?
The root cause is that distanceUnit is not included in the SplitTransactionSplitParam API parameters, so the backend never receives the updated unit for child transactions during a split save.
Here's the data flow:
When the user changes the rate on a split item, setDraftSplitTransaction calls getUpdatedTransaction (TransactionUtils/index.ts:757-773), which correctly converts quantityand updates distanceUnit on the draft transaction.
When saving the split edit, updateSplitExpenseField (Split.ts:2307-2310) correctly spreads the draft's customUnit (including the new distanceUnit) into the splitExpenses array.
When the overall split is submitted, updateSplitTransactions constructs the API parameters at Split.ts:1091-1111:
quantity: split.customUnit?.quantity, // ✅ Included (converted value)
customUnitRateID: split.customUnit?.customUnitRateID, // ✅ Included
// ❌ distanceUnit is NOT included
While the client's optimistic update is correct (via buildOptimisticTransaction with the full customUnit at Split.ts:1187), the backend stores the child transaction with the old distanceUnit because it was never sent. When the server response returns, it overwrites the optimistic data, resulting in: new converted quantity + old unit.
This causes the display to show 16.09 mi (interpreting the km-converted quantity as miles), and the distance editor to double-convert when opened.
What changes do you think we should make in order to solve the problem?
Add distanceUnit to SplitTransactionSplitParam in src/libs/API/parameters/SplitTransactionParams.ts:
Add distanceUnit?: string to the type definition
Pass distanceUnit when constructing splits in src/libs/actions/IOU/Split.ts around line 1106:
Add distanceUnit: split.customUnit?.distanceUnit to the splits mapping alongside quantity and customUnitRateID
Ensure the backend handles the distanceUnit parameter — the backend's SplitTransaction command handler needs to store the distanceUnit on each child transaction when provided.
What alternative solutions did you explore? (Optional)
An alternative would be to never store distanceUnit on individual transactions and always derive it from the policy's current distance unit. However, this would break for P2P distance transactions that may have a different unit than the policy, and for historical transactions where the policy unit has changed since creation. Explicitly passing distanceUnit in the API params is the safer, more explicit approach.
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.
changed the title [-]Distance is saved with new value and old unit after changing rate with different unit[/-][+][$250] Distance is saved with new value and old unit after changing rate with different unit[/+]on Feb 27, 2026
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 @kadiealexander (
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 splitting a distance expense and then changing the workspace's distance unit (e.g., mi → km), editing a split item's rate causes the distance value to be correctly converted but the old unit label to persist. For example, changing from a miles rate to a km rate converts
10 mito16.09, but saves it as16.09 miinstead of16.09 km. Opening the distance editor then further converts the already-converted value, producing a double-conversion (e.g.,25.90 km).What is the root cause of that problem?
The root cause is that
distanceUnitis not included in theSplitTransactionSplitParamAPI parameters, so the backend never receives the updated unit for child transactions during a split save.Here's the data flow:
When the user changes the rate on a split item,
setDraftSplitTransactioncallsgetUpdatedTransaction(TransactionUtils/index.ts:757-773), which correctly convertsquantityand updatesdistanceUniton the draft transaction.When saving the split edit,
updateSplitExpenseField(Split.ts:2307-2310) correctly spreads the draft'scustomUnit(including the newdistanceUnit) into thesplitExpensesarray.When the overall split is submitted,
updateSplitTransactionsconstructs the API parameters atSplit.ts:1091-1111:The
SplitTransactionSplitParamtype (SplitTransactionParams.ts:3-22) does not have adistanceUnitfield.While the client's optimistic update is correct (via
buildOptimisticTransactionwith the fullcustomUnitatSplit.ts:1187), the backend stores the child transaction with the olddistanceUnitbecause it was never sent. When the server response returns, it overwrites the optimistic data, resulting in: new converted quantity + old unit.This causes the display to show
16.09 mi(interpreting the km-converted quantity as miles), and the distance editor to double-convert when opened.What changes do you think we should make in order to solve the problem?
Add
distanceUnittoSplitTransactionSplitParaminsrc/libs/API/parameters/SplitTransactionParams.ts:distanceUnit?: stringto the type definitionPass
distanceUnitwhen constructing splits insrc/libs/actions/IOU/Split.tsaround line 1106:distanceUnit: split.customUnit?.distanceUnitto the splits mapping alongsidequantityandcustomUnitRateIDEnsure the backend handles the
distanceUnitparameter — the backend'sSplitTransactioncommand handler needs to store thedistanceUniton each child transaction when provided.What alternative solutions did you explore? (Optional)
An alternative would be to never store
distanceUniton individual transactions and always derive it from the policy's current distance unit. However, this would break for P2P distance transactions that may have a different unit than the policy, and for historical transactions where the policy unit has changed since creation. Explicitly passingdistanceUnitin the API params is the safer, more explicit approach.Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR, or@MelvinBot <your feedback>to refine this analysis.melvin-bot commentedon Feb 27, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @suneox (
External)[-]Distance is saved with new value and old unit after changing rate with different unit[/-][+][$250] Distance is saved with new value and old unit after changing rate with different unit[/+]melvin-bot commentedon Feb 27, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022027246443158234016
lakchote commentedon Feb 27, 2026
We have the same issue for non split expenses see https://expensify.slack.com/archives/C01GTK53T8Q/p1772177861474219?thread_ts=1772167056.020339&cid=C01GTK53T8Q
Closing the issue.