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 - Duplicated expense amount is the original amount instead of the edited amount #84194
Version Number: 9.3.31-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:#82005 Email or phone of affected tester (no customers):jsodijnsoinjdojoijsoid@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:
Go to staging.new.expensify.com
Go to workspace chat.
Create a manual distance expense.
Open the distance expense.
Click Amount.
Edit the amount and save it.
Click More > Duplicate expense.
Open the duplicated expense.
Expected Result:
Duplicated expense amount will be the edited amount (similar to OD).
Actual Result:
Duplicated expense amount is the original amount instead of the edited amount.
👋 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.
When a user edits the amount on a distance expense and then duplicates it, the duplicated expense shows the original rate-calculated amount instead of the user's manually edited amount.
What is the root cause of that problem?
PR #82005 re-enabled distance expense duplication by removing a blanket block and routing duplicated distance expenses through createDistanceRequest. The problem has two parts:
modifiedAmount is explicitly cleared during duplication at Duplicate.ts:573 — when a user edits an expense amount, the edit is stored in modifiedAmount, but the duplication code sets modifiedAmount: undefined.
The backend recalculates the amount from scratch — CreateDistanceRequestParams (definition) does not include an amount field. When the duplicated distance request is created, the backend receives only waypoints, distance, and customUnitRateID, then calculates amount = distance * rate, producing the original amount and overwriting the correct optimistic value.
The frontend actually computes the correct edited amount optimistically (via getTransactionDetails → getAmount which respects modifiedAmount), but the backend response overwrites it with the recalculated original amount.
What changes do you think we should make in order to solve the problem?
When duplicating a distance expense whose amount was manually edited, preserve the modifiedAmount on the duplicated transaction instead of clearing it to undefined. Specifically:
In Duplicate.ts, when building transactionParams for duplication, check if the original transaction has a valid modifiedAmount (using hasValidModifiedAmount from TransactionUtils). If it does, pass the original modifiedAmount value through instead of setting it to undefined.
This way, even though the backend recalculates the base amount from distance/rate, the modifiedAmount field will be preserved on the duplicated transaction, and getAmount() (which already prioritizes modifiedAmount over amount) will display the correct edited value.
What alternative solutions did you explore? (Optional)
Adding an amount field to CreateDistanceRequestParams so the backend uses the provided amount instead of recalculating. This would require backend changes and is more invasive.
Skipping waypoint processing for duplicated distance expenses with edited amounts (not sending the receipt as OPEN state). This could break the route display on the duplicate.
Adding an amount field to CreateDistanceRequestParams so the backend uses the provided amount instead of recalculating. This would require backend changes and is more invasive.
I think we should go with this alternative solution, or another alternative is adding modifiedAmount field to CreateDistanceRequestParams
Hmm, wasn't aware you could edit the amount for a distance expense. It seems a bit counter-intuitive - what are the Distance and Rate fields for if you just enter a manual value? 😄 I don't know how often manually editing the amount is done, but I can see an argument for this not being a blocker.
This way, even though the backend recalculates the base amount from distance/rate, the modifiedAmount field will be preserved on the duplicated transaction
I'm pretty sure modifiedAmount wouldn't be preserved by the BE. We explicitly clear modifiedAmount because for the duplicated transaction it's meant to act as a fresh transaction (so the "modified" state shouldn't be preserved).
I think the BE solution is the only one that makes sense here. I'm guessing the Transaction_Duplicate command for OD handles this all in the BE. cc @JS00001
Activity
melvin-bot commentedon Mar 4, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #82005
melvin-bot commentedon Mar 4, 2026
💬 A slack conversation has been started in #expensify-open-source
melvin-bot commentedon Mar 4, 2026
Triggered auto assignment to @CortneyOfstad (
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 Mar 4, 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 Mar 4, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user edits the amount on a distance expense and then duplicates it, the duplicated expense shows the original rate-calculated amount instead of the user's manually edited amount.
What is the root cause of that problem?
PR #82005 re-enabled distance expense duplication by removing a blanket block and routing duplicated distance expenses through
createDistanceRequest. The problem has two parts:modifiedAmountis explicitly cleared during duplication atDuplicate.ts:573— when a user edits an expense amount, the edit is stored inmodifiedAmount, but the duplication code setsmodifiedAmount: undefined.The backend recalculates the amount from scratch —
CreateDistanceRequestParams(definition) does not include anamountfield. When the duplicated distance request is created, the backend receives onlywaypoints,distance, andcustomUnitRateID, then calculatesamount = distance * rate, producing the original amount and overwriting the correct optimistic value.The frontend actually computes the correct edited amount optimistically (via
getTransactionDetails→getAmountwhich respectsmodifiedAmount), but the backend response overwrites it with the recalculated original amount.What changes do you think we should make in order to solve the problem?
When duplicating a distance expense whose amount was manually edited, preserve the
modifiedAmounton the duplicated transaction instead of clearing it toundefined. Specifically:Duplicate.ts, when buildingtransactionParamsfor duplication, check if the original transaction has a validmodifiedAmount(usinghasValidModifiedAmountfromTransactionUtils). If it does, pass the originalmodifiedAmountvalue through instead of setting it toundefined.modifiedAmountfield will be preserved on the duplicated transaction, andgetAmount()(which already prioritizesmodifiedAmountoveramount) will display the correct edited value.What alternative solutions did you explore? (Optional)
amountfield toCreateDistanceRequestParamsso the backend uses the provided amount instead of recalculating. This would require backend changes and is more invasive.OPENstate). This could break the route display on the duplicate.Detailed Investigation
Evidence Chain
Duplicate.tsmodifiedAmount: undefined— clears the edited amountDuplicate.tscreateDistanceRequestCreateDistanceRequestParams.tsamountfield — backend recalculates from rate/distanceIOU/index.tsOPENfor map-based distance, triggering backend recalcIOU/index.tspendingFields.waypoints = ADDtriggers backend route/amount calculationTransactionUtils/index.tsgetAmount()correctly returns edited amount frommodifiedAmountData Flow
amount=-5000,modifiedAmount=-7500(edited from $50.00 to $75.00)duplicateExpenseTransaction()calledgetTransactionDetails()resolves amount to7500(correctly usesmodifiedAmount)transactionParamsbuilt withamount=7500,modifiedAmount=undefined(cleared at line 573)createDistanceRequest()called with original waypoints-7500) temporarilyCreateDistanceRequestParamssent to backend without amount — only waypoints, distance, customUnitRateIDConfidence: High
Both independent code investigations converge on the same root cause with specific file:line evidence.
Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR, or@MelvinBot <your feedback>to refine this analysis.hoangzinh commentedon Mar 5, 2026
I think we should go with this alternative solution, or another alternative is adding modifiedAmount field to CreateDistanceRequestParams
hoangzinh commentedon Mar 5, 2026
cc @jjcoffee
jjcoffee commentedon Mar 5, 2026
Hmm, wasn't aware you could edit the amount for a distance expense. It seems a bit counter-intuitive - what are the
DistanceandRatefields for if you just enter a manual value? 😄 I don't know how often manually editing the amount is done, but I can see an argument for this not being a blocker.I'm pretty sure
modifiedAmountwouldn't be preserved by the BE. We explicitly clearmodifiedAmountbecause for the duplicated transaction it's meant to act as a fresh transaction (so the "modified" state shouldn't be preserved).I think the BE solution is the only one that makes sense here. I'm guessing the
Transaction_Duplicatecommand for OD handles this all in the BE. cc @JS00001hoangzinh commentedon Mar 5, 2026
Agreed
JS00001 commentedon Mar 5, 2026
Agreed NAB, lets fix this though please
JS00001 commentedon Mar 5, 2026
Closing out in favor of #84280, so there's less noise