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
Expense - Error after editing amount/distance/rate or adding distance split in self DM #91878
Version Number: 9.3.84-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:#84382 Email or phone of affected tester (no customers):soidjnosnjdoijsioj@gmail.com Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Mac 26.5 / Chrome App Component: Money Requests
Action Performed:
Go to staging.new.expensify.com
Go to self DM.
Create a distance expense.
Open the expense.
Click More > Split > Save.
Open any split.
Click Amount.
Edit the amount OR Click Add split and edit the amount > Save.
Expected Result:
Distance expense will be saved after editing amount or adding split with new amount.
Actual Result:
Error shows up after editing amount or adding split with new amount.
This issue also happens when user edits distance or rate instead of amount in Step 7-8.
👋 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.
There are two distinct failure paths introduced by #84382, both triggered when editing distance splits in self-DM:
1. isUnitRateIDOutOfPolicy validation blocks Save (affects all edit types)
In SplitExpensePage.tsx:218-239, every distance split item is validated against the effective policy's mileage rates before the save is allowed. For self-DM splits, useSplitEffectivePolicy must resolve the policy through a multi-step fallback chain (customUnitID lookup → customUnitRateID lookup → policyForMovingExpenses). If this chain fails to resolve a policy, effectivePolicy is undefined and isUnitRateIDOutOfPolicy is set to true at line 229-231, which blocks the save with the modal: "Please fix the distance rate error and try again."
Critically, when re-entering the split flow for existing splits, initSplitExpense rebuilds the draft at lines 138-151without passing customUnit or existingTransaction to buildOptimisticTransaction — unlike the initial split creation at lines 239-256 which includes both. This means the re-entry draft lacks comment.customUnit on the draft transaction itself, making the useSplitEffectivePolicy fallback depend solely on the transaction parameter (the original parent). If the original transaction's customUnitRateID doesn't match any loaded policy (e.g., workspace was deleted or rates changed), policy resolution fails.
2. Zero-amount validation blocks Save for "Add split" (distance-specific)
In addSplitExpenseField, amount redistribution is explicitly skipped for distance requests (if (!isDistanceRequest && shouldRedistribute)), so newly added splits start with amount: 0. The computeSplitSaveErrorMessage check then rejects the save with "Please enter a valid amount before continuing" — even though for distance expenses the amount is meant to be derived from distance × rate, not entered directly.
What changes do you think we should make in order to solve the problem?
Fix 1: Pass customUnit and existingTransaction when rebuilding draft for existing splits
In initSplitExpense (SplitExpenses.ts:138-151), add customUnit and existingTransaction to the buildOptimisticTransaction call for the re-entry path, matching what the initial-creation path already does:
This ensures useSplitEffectivePolicy can resolve the policy from the draft transaction's customUnit even when re-editing existing splits.
Fix 2: Handle zero-amount validation for distance "Add split"
In computeSplitSaveErrorMessage (SplitExpenseUtils.ts:108), skip the zero-amount check for distance requests (similar to how the total-mismatch checks already skip with !isDistance), OR have addSplitExpenseField calculate an initial distance and amount for the new split item based on the resolved mileage rate, rather than leaving it at zero.
What alternative solutions did you explore? (Optional)
An alternative for Fix 1 is to modify useSplitEffectivePolicy to always attempt a direct policy search by customUnitRateID from the split items themselves (not just from the draft transaction), but this would be more invasive and add complexity to the hook. Fixing the data passed to buildOptimisticTransaction is more surgical and addresses the root cause directly.
Investigation details
Key code paths investigated:
Split flow entry: initSplitExpense (SplitExpenses.ts:89-265) — creates draft and navigates to SplitExpensePage. Initial creation (line 239) passes customUnit; re-entry for existing splits (line 138) does not.
Rate resolution fallback: resolveSplitMileageRate (SplitExpenseItems.ts:90-139) — derives rate from amount / quantity when policy is unavailable.
Alternative explanation considered and not fully ruled out: The error could originate from the backend rejecting the split update API call, with the error surfaced via draftTransaction.errors and the useEffect at line 241-247. Without access to backend logs for the specific test scenario, this can't be confirmed or eliminated, but the frontend validation paths above are more likely given the described behavior.
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.
This issue has not been updated in over 15 days. @lakchote, @ZhenjaHorbach eroding to Monthly issue.
P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!
Activity
applause-bot commentedon May 27, 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/c166b6a7775d39237237dc4d0efb88323a98d15fba231a676e47b29423347101
melvin-bot commentedon May 27, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #84382
melvin-bot commentedon May 27, 2026
💬 A slack conversation has been started in #expensify-open-source
github-actions commentedon May 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 May 27, 2026
Proposal
What is the root cause of that problem?
There are two distinct failure paths introduced by #84382, both triggered when editing distance splits in self-DM:
1.
isUnitRateIDOutOfPolicyvalidation blocks Save (affects all edit types)In
SplitExpensePage.tsx:218-239, every distance split item is validated against the effective policy's mileage rates before the save is allowed. For self-DM splits,useSplitEffectivePolicymust resolve the policy through a multi-step fallback chain (customUnitID lookup → customUnitRateID lookup → policyForMovingExpenses). If this chain fails to resolve a policy,effectivePolicyis undefined andisUnitRateIDOutOfPolicyis set totrueat line 229-231, which blocks the save with the modal: "Please fix the distance rate error and try again."Critically, when re-entering the split flow for existing splits,
initSplitExpenserebuilds the draft at lines 138-151 without passingcustomUnitorexistingTransactiontobuildOptimisticTransaction— unlike the initial split creation at lines 239-256 which includes both. This means the re-entry draft lackscomment.customUniton the draft transaction itself, making theuseSplitEffectivePolicyfallback depend solely on thetransactionparameter (the original parent). If the original transaction'scustomUnitRateIDdoesn't match any loaded policy (e.g., workspace was deleted or rates changed), policy resolution fails.2. Zero-amount validation blocks Save for "Add split" (distance-specific)
In
addSplitExpenseField, amount redistribution is explicitly skipped for distance requests (if (!isDistanceRequest && shouldRedistribute)), so newly added splits start withamount: 0. ThecomputeSplitSaveErrorMessagecheck then rejects the save with "Please enter a valid amount before continuing" — even though for distance expenses the amount is meant to be derived from distance × rate, not entered directly.What changes do you think we should make in order to solve the problem?
Fix 1: Pass
customUnitandexistingTransactionwhen rebuilding draft for existing splitsIn
initSplitExpense(SplitExpenses.ts:138-151), addcustomUnitandexistingTransactionto thebuildOptimisticTransactioncall for the re-entry path, matching what the initial-creation path already does:customUnit: originalTransaction?.comment?.customUnitexistingTransaction: originalTransactionodometerStart: originalTransaction?.comment?.odometerStartodometerEnd: originalTransaction?.comment?.odometerEndThis ensures
useSplitEffectivePolicycan resolve the policy from the draft transaction'scustomUniteven when re-editing existing splits.Fix 2: Handle zero-amount validation for distance "Add split"
In
computeSplitSaveErrorMessage(SplitExpenseUtils.ts:108), skip the zero-amount check for distance requests (similar to how the total-mismatch checks already skip with!isDistance), OR haveaddSplitExpenseFieldcalculate an initial distance and amount for the new split item based on the resolved mileage rate, rather than leaving it at zero.What alternative solutions did you explore? (Optional)
An alternative for Fix 1 is to modify
useSplitEffectivePolicyto always attempt a direct policy search bycustomUnitRateIDfrom the split items themselves (not just from the draft transaction), but this would be more invasive and add complexity to the hook. Fixing the data passed tobuildOptimisticTransactionis more surgical and addresses the root cause directly.Investigation details
Key code paths investigated:
initSplitExpense(SplitExpenses.ts:89-265) — creates draft and navigates to SplitExpensePage. Initial creation (line 239) passescustomUnit; re-entry for existing splits (line 138) does not.useSplitEffectivePolicy(useSplitEffectivePolicy.ts:27-59) — resolution chain: report.policyID → customUnitID → customUnitRateID → policyForMovingExpenses.SplitExpensePagelines 218-239 and lines 279-287.updateSplitExpenseAmountField(SplitExpenseItems.ts:634-706) — handles inline amount changes, recalculates distance for distance splits.addSplitExpenseField(SplitExpenseItems.ts:287-360) — skips redistribution for distance at line 349.resolveSplitMileageRate(SplitExpenseItems.ts:90-139) — derives rate fromamount / quantitywhen policy is unavailable.Alternative explanation considered and not fully ruled out: The error could originate from the backend rejecting the split update API call, with the error surfaced via
draftTransaction.errorsand theuseEffectat line 241-247. Without access to backend logs for the specific test scenario, this can't be confirmed or eliminated, but the frontend validation paths above are more likely given the described behavior.Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR,@MelvinBot <your feedback>to refine this analysis, or explain why you are rejecting Melvin's proposal.lakchote commentedon May 28, 2026
Since we've added the guard to hide the selfDM splits feature in production in the PR #91932, I'm going to remove the deploy blocker label @mountiny
15 remaining items
lakchote commentedon Jun 26, 2026
I have a BE PR up for review to fix this cc @pecanoro
lakchote commentedon Jun 26, 2026
Not overdue, see above
lakchote commentedon Jun 29, 2026
Not overdue, the BE fix has been merged and deployed
lakchote commentedon Jul 7, 2026
Not overdue ^
melvin-bot commentedon Jul 9, 2026
This issue has not been updated in over 15 days. @lakchote, @ZhenjaHorbach eroding to Monthly issue.
P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!
lakchote commentedon Aug 31, 2026
I think we can close this one