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
[Due for payment 2026-08-17] [$250] Distance - Rate field is blank when distance is submitted from self DM offline #93575
Version Number: 9.4.7-1 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: EDGE https://github.com/Expensify/Expensify/issues/487450 Email or phone of affected tester (no customers): Issue reported by: Applause Internal Team
Action Performed:
Go to staging.new.expensify.com
Create two workspaces.
Go to workspace settings of the second workspace > More features.
Enable Distance rates.
Go to Distance rates.
Click Settings > Unit.
Change to another unit (Kilometers if Miles is the default rate).
Go to self DM.
Create a distance expense.
Go offline.
Click Submit it to someone.
Select the second workspace chat with modified distance unit.
On confirm page, click Rate and select default rate.
Click Create expense.
Open the distance expense.
Click Rate field.
Expected Result:
Rate field will show the selected rate.
Actual Result:
Rate field is blank when distance is submitted from self DM offline.
⚠️Medium confidence. The investigation pins down the area (the rate is lost/unresolvable when a track expense is moved from self-DM to a workspace offline), but the exact line that renders the field truly blank still needs runtime confirmation — see caveat below.
What is the root cause of that problem?
When you submit an existing self-DM (track) distance expense to a workspace offline and pick a rate on the confirm page, the selected rate is written to the draft transaction by setMoneyRequestDistanceRate. That write also sets defaultP2PRate: null whenever a policy is present, which removes the P2P fallback the self-DM expense was relying on.
At display time, MoneyRequestView resolves the rate via DistanceRequestUtils.getRate. Because the expense is now reported (no longer unreported), distanceOriginalPolicy is undefined and the lookup runs against the destination workspace policy only. If the chosen customUnitRateID isn't resolvable in that policy's customUnits rates at that moment and the P2P fallback was nulled, getRate returns no name/rate/currency, and the Rate field ends up empty.
The workspace's unit being changed (Miles → Km in the repro) makes the mismatch more likely: the moved transaction's stored unit/rate doesn't line up with the destination policy's distance custom unit. The DistanceRequestController tries to reconcile a mismatched rate by matching on rate+unit, but offline it can fail to find a match and leave the transaction with a rate that doesn't resolve against the target policy.
What changes do you think we should make in order to solve the problem?
When a track expense is moved to a workspace, ensure the optimistic transaction carries a complete, self-consistent customUnit for the destination policy — i.e. a customUnitRateID that exists in that policy's distance custom unit, paired with the matching customUnitID and unit. Concretely:
In the move/submit flow, don't null defaultP2PRate until a valid workspace rate is confirmed resolvable, so the field falls back to a displayable value instead of blank.
In getRate, when the stored customUnitRateID can't be found in the resolved policy for a moved expense, fall back to the policy's default mileage rate rather than returning an empty rate.
What alternative solutions did you explore? (Optional)
Investigation details & open questions
Important caveat (why this is medium, not high, confidence): Tracing the display code, getRateForExpenseDisplay / getFormattedRateValue normally return some string (Default rate offline, Pending online, or Rate out of policy) rather than a truly empty one. So either (a) the user perceives one of those placeholders as "blank", or (b) the blank comes from a more specific data inconsistency in the offline-moved transaction. Confirming the actual rendered string (vs. truly empty) from the repro video / runtime would tell us which.
getRateID — returns FAKE_P2P_ID when the rate is missing (so a missing rate should fall to P2P, not blank — supporting the "data inconsistency" theory).
useDistanceRateOriginalPolicy is only used for unreported expenses, so it doesn't help once the expense is moved to a workspace.
Open questions for confirmation:
Is the field truly empty, or showing Pending / Rate out of policy / Default rate?
Does the destination workspace policy snapshot actually contain the selected customUnitRateID at display time (offline)?
Does the optimistic moved transaction carry a customUnitID matching the destination policy's distance custom unit?
Possibly related:#82960 — Merchant & Amount show "Scanning" when distance is submitted from self DM offline (same self-DM → workspace offline distance flow).
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/93575) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
Replaces my earlier proposal. The root cause is still the rate ID mismatch in the offline self-DM submit path, but this version uses the current proposal template and anchors the fix to the per-item transaction conversion.
Proposal
What is the root cause of that problem?
Distance-rate selection is stored on transaction.comment.customUnit.customUnitRateID, but the offline submit-from-self-DM path does not consistently use the distance transaction item that is being converted when it builds the optimistic/API params.
The tracked-expense submit flow starts by cloning the self-DM transaction into a draft, so the draft begins with the original self-DM/P2P rate. When the user selects the workspace rate on the confirmation page, IOURequestStepDistanceRate writes the selected customUnitRateID to the transaction draft.
However, useExpenseSubmission computes one customUnitRateID from the page-level transaction before iterating the transactions collection, then passes that same value into the conversion params for every item. The same hook already reads distance quantity from each item because submit-from-self-DM can have a page-level transaction that has not inherited the distance custom unit, but it does not do the same for the rate ID.
Offline, before the backend can reconcile anything, the converted workspace expense can keep FAKE_P2P_ID or another stale rate ID instead of the selected workspace rate. The expense detail and Rate picker resolve rates from the workspace policy by stored customUnitRateID; a self-DM/P2P ID does not exist in that workspace rate map, so the Rate field opens blank even though the workspace has a default rate.
What changes do you think we should make in order to solve the problem?
In useExpenseSubmission, resolve the distance customUnitRateID per submitted item before constructing transactionParams.
Concretely:
Add a small helper in the hook that returns a policy-valid rate ID for the current item.
For distance items, prefer getRateID(item) instead of the page-level transaction rate.
If the item still has FAKE_P2P_ID or an empty rate while submitting to a policy expense chat, fall back through the same workspace selection rules used elsewhere: last selected distance rate for the policy, date-aware eligible rate, then policy default.
For non-distance items, keep the current behavior.
Use that item-level value in the requestMoney() loop for transactionParams.customUnitRateID.
Use the same item-level value in the trackExpense() loop for submit/categorize/share transaction params.
Keep the normal createDistanceRequest() path using the single confirmation transaction, since that path is not converting a separate list of tracked transaction items.
This makes both the offline optimistic transaction and deferred API request carry the selected workspace rate immediately.
What alternative solutions did you explore? (Optional)
I considered fixing the Rate edit page to show a default option when the stored ID cannot be resolved, but that would only hide the bad optimistic data. The transaction and API payload would still carry the stale/P2P rate ID.
I also considered removing the moving-track guard in DistanceRequestController that skips auto-selecting a workspace rate while the draft is still FAKE_P2P_ID, but that would change confirmation-page behavior and could silently override the tracked expense before the user chooses a workspace rate. The safer boundary is the final submit conversion, where we know the target policy and exact item being converted.
When the user converts a tracked distance expense from self-DM into a real request, the optimistic transaction built on the client has no customUnitRateID. The local view of the new expense therefore can't resolve a rate at render time — getRate falls through to undefined and rateToDisplay is blank. Online this is masked because the server response sends the canonical transaction back and overwrites the optimistic copy; offline the response is buffered indefinitely so the blank state is what the user sees.
Online, the server's response carries the correct customUnitRateID and overwrites the optimistic transaction — the blank flashes for a moment and then resolves. Offline, the response is queued/buffered and the user is left looking at the blank state.
What changes do you think we should make in order to solve the problem?
Thread customUnitRateID through the destructuring in getMoneyRequestInformation and into buildOptimisticTransaction so the optimistic transaction reflects the rate the user chose:
buildOptimisticTransaction already consumes customUnitRateID from its own transactionParams and writes it to comment.customUnit.customUnitRateID (the else branch above), so no change is needed in TransactionUtils — only the plumbing between the two functions.
The same fix lands behavior for the non-convert path: any caller that already passes customUnitRateID (e.g. the regular distance-create flow) gets it propagated into the optimistic transaction instead of relying on the server response to backfill it. Offline rate display works in both flows after this change.
The existingTransaction branch and split-expense customUnit branch are untouched, so transactions that already carry a full customUnit (split, edit) keep their current behavior.
What alternative solutions did you explore?
Patch setCustomUnitRateID to also write the chosen rateID onto the committed transaction, not just the draft. Wrong layer — the committed transaction doesn't exist yet at confirmation-page time; what's missing is that the optimistic transaction the convert flow creates doesn't carry the rateID. Threading it through the builder is the change that's actually needed.
Construct a full customUnit object in the convert-track caller and pass that through. Works but duplicates logic that buildOptimisticTransaction already has for assembling the customUnit from customUnitRateID, distance, and distanceUnit. Passing the rateID is the smaller change.
When a tracked (self‑DM) distance expense is moved to a workspace while offline (Submit it to someone), the optimistically‑moved expense's transaction thread report has no policyID — the self‑DM origin carries none, and the backend hasn't responded yet to populate it.
On the Rate selection page, IOURequestStepDistanceRate resolves the policy through usePolicyForTransaction({reportPolicyID: report?.policyID}), which returns reportPolicy ?? policyDraft. Since report?.policyID is empty here, policyForTransaction is undefined, so policy is undefined and getMileageRates(policy, …) returns {} → the rate list renders empty.
The page already has a fallback that finds the owning policy by the transaction's customUnitRateID, but it is gated behind isEditingSplit, so it never runs for this non‑split move flow.
(The expense detail row still shows Default Rate because MoneyRequestView resolves the policy from the parent expense report's policyID, which is populated — not the thread report's.) Online, the backend returns the thread report with its policyID, so the lookup succeeds and the list isn't empty.
What changes do you think we should make in order to solve the problem?
Broaden the existing rate‑ID policy fallback so it also runs when policyForTransaction is missing — not only for splits. In IOURequestStepDistanceRate.tsx, change the guard of policyByCustomUnitRateID from isEditingSplit to !policyForTransaction:
The moved transaction still carries the selected workspace customUnitRateID, so even with an empty report?.policyID this resolves the correct destination workspace and getMileageRates returns its rates. The existing !isP2PRate/!== FAKE_P2P_ID guards keep genuine P2P expenses untouched, and when policyForTransaction is present (the normal case) the fallback stays inert.
For symmetry we can apply the same !policyForTransaction guard to policyByCustomUnitID (it already returns undefined for this flow because the optimistic transaction has no customUnitID offline, but it keeps the two fallbacks consistent once the backend populates customUnitID).
What alternative solutions did you explore? (Optional)
Populate the moved expense's transaction thread report policyID optimistically inside convertTrackedExpenseToRequest so usePolicyForTransaction resolves the policy directly, mirroring the data the backend returns online. This fixes the resolution at the source, but it edits the optimistic‑data builder and is broader/riskier than the display‑side change above; since the rate‑ID fallback already exists for the split case, extending it keeps the fix localized and pattern‑consistent.
🚨 Edited by proposal-police: This proposal was edited at 2026-07-06 04:06:11 UTC.
Proposal
What is the root cause of that problem?
There are two gaps in the optimistic data written when a self-DM tracked distance expense is submitted to a workspace, and both are only visible offline because the server response papers over them on reconnect.
Gap 1 — the blank rate picker (the reported symptom).convertTrackedExpenseToRequest re-parents the existing self-DM transaction thread onto the workspace expense report, but the optimistic merge only writes parentReportActionID/parentReportID — never the destination policyID or chatReportID:
A self-DM thread has no policyID, so offline the policy is undefined, getMileageRates(undefined) returns {}, and the picker renders an empty list. The shape the server returns is what buildTransactionThread already documents — it sets chatReportID and policyID alongside the parent fields:
Gap 2 — the picked rate isn't kept. The rate selected on the confirm page is written to the draft and forwarded to the API as customUnitRateID/customUnitID (via workspaceParams), but the optimistic transaction never receives it: the moved transaction keeps its stale self-DM custom unit until the server responds. So even with Gap 1 fixed, the picker lists the workspace rates without highlighting the one the user chose.
What changes do you think we should make in order to solve the problem?
Fix both gaps inside convertTrackedExpenseToRequest — the conversion boundary where the optimistic data diverges from the server response — so the optimistic state matches what the backend returns.
1. Extend the thread re-parent merge with the destination policyID/chatReportID, and restore the originals in failureData:
workspaceParams is undefined for a P2P "submit to an individual", so that path is untouched.
2. In the workspaceParams branch (the path that calls addTrackedExpenseToPolicy), when isDistance, apply the destination custom unit to the moved transaction optimistically, with a failureData rollback:
Everything needed is already in scope in that function: customUnitRateID and isDistance are destructured from transactionParams, sourceTransaction is already computed at
), so the merge targets the right record. These merges are pushed after the builder's optimistic SET of the transaction, so ordering is safe.
With both in place the picker resolves the workspace policy, lists its rates, and pre-selects the picked rate offline — and the change is confined to the one action that creates the broken optimistic state.
What alternative solutions did you explore? (Optional)
Please re-state the problem that we are trying to solve in this issue.
Moving a self-DM distance expense to a workspace ("Submit it to someone") offline and picking a rate on the confirm page leaves the Rate field blank when you reopen the expense. Expected: the selected rate.
What is the root cause of that problem?
The optimistic transaction for the moved expense is built from the stored self-DM (P2P) transaction, not the draft holding the rate the user just picked — so the selected customUnitRateID never lands on it, and offline (no backend recompute) the rate can't resolve.
Picking the rate writes it to the draft (setMoneyRequestDistanceRate: customUnit.customUnitRateID, defaultP2PRate:null).
On submit, useExpenseSubmission passes the stored P2P transaction (not the draft) as existingTransaction:
MoneyRequestBuilder never forwards the picked customUnitRateID into buildOptimisticTransaction, so the stored P2P customUnit wins the fastMerge (MoneyRequestBuilder#L1466).
The new transaction stays FAKE_P2P_ID; getRate then takes the P2P branch (DistanceRequestUtils#L562-566) whose offline value is unresolved → blank.
What changes do you think we should make in order to solve the problem?
Seed the optimistic transaction from the draft for the move flow: in useExpenseSubmission, for SUBMIT pass existingTransactionDraft (or undefined) as existingTransaction, so requestMoney's action === SUBMIT ? existingTransactionDraft branch runs — the draft already carries the picked rate, unit and defaultP2PRate:null. As a safeguard, also forward customUnitRateID through MoneyRequestBuilder into buildOptimisticTransaction (already consumed there).
Regression safety: only the move-from-self-DM optimistic base changes; normal workspace creation already passes the draft, so other flows are untouched.
What alternative solutions did you explore? (Optional)
Patch getRateForP2P's offline fallback — incomplete: shows a P2P value, not the selected rate, and never fixes why a moved expense stays P2P.
Set the rate only in convertTrackedExpenseToRequest params — fixes online/API, not the offline optimistic transaction.
Clicking the Rate row from the submitted expense detail page navigates to MONEY_REQUEST_STEP_DISTANCE_RATE with transactionThreadReport.reportID as the route reportID:
In this offline submit-from-self-DM flow, the Rate step cannot rely on that route report to resolve the workspace policy. IOURequestStepDistanceRate already has fallback logic to find the policy from the transaction’s customUnitID or customUnitRateID, but that fallback is gated behind isEditingSplit:
This issue is not a split edit. It is an edit of a submitted distance expense, so the fallback never runs. As a result, policy stays undefined, DistanceRequestUtils.getMileageRates(policy, false, currentRateID) returns no rates, and the Rate selector renders an empty list:
Use that condition for policyByCustomUnitID and policyByCustomUnitRateID.
Keep the paid-policy fallback limited to split edits, since that fallback is broader and not needed for this issue.
Tests that should be added:
Add a focused UI/unit test for IOURequestStepDistanceRate where the route report has no usable policy, the transaction has a workspace customUnitRateID, and the policy collection contains that rate. Verify the rate option is rendered and selected.
Cover the P2P rate case to confirm we do not incorrectly resolve a workspace policy for FAKE_P2P_ID.
I considered changing the optimistic distance transaction creation to always include customUnitID, but the Rate step already supports resolving the policy by customUnitRateID for optimistic transactions. The missing piece is that this fallback is restricted to split edits, so widening the existing fallback to all edited distance expenses is the smaller root-cause fix.
Demo
Video_2026-06-15_15-56-08.mp4
What alternative solutions did you explore? (Optional)
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion:
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Activity
MelvinBot commentedon Jun 15, 2026
Proposal
What is the root cause of that problem?
When you submit an existing self-DM (track) distance expense to a workspace offline and pick a rate on the confirm page, the selected rate is written to the draft transaction by
setMoneyRequestDistanceRate. That write also setsdefaultP2PRate: nullwhenever a policy is present, which removes the P2P fallback the self-DM expense was relying on.At display time,
MoneyRequestViewresolves the rate viaDistanceRequestUtils.getRate. Because the expense is now reported (no longer unreported),distanceOriginalPolicyis undefined and the lookup runs against the destination workspace policy only. If the chosencustomUnitRateIDisn't resolvable in that policy'scustomUnitsrates at that moment and the P2P fallback was nulled,getRatereturns noname/rate/currency, and the Rate field ends up empty.The workspace's unit being changed (Miles → Km in the repro) makes the mismatch more likely: the moved transaction's stored unit/rate doesn't line up with the destination policy's distance custom unit. The
DistanceRequestControllertries to reconcile a mismatched rate by matching onrate+unit, but offline it can fail to find a match and leave the transaction with a rate that doesn't resolve against the target policy.What changes do you think we should make in order to solve the problem?
When a track expense is moved to a workspace, ensure the optimistic transaction carries a complete, self-consistent
customUnitfor the destination policy — i.e. acustomUnitRateIDthat exists in that policy's distance custom unit, paired with the matchingcustomUnitIDand unit. Concretely:defaultP2PRateuntil a valid workspace rate is confirmed resolvable, so the field falls back to a displayable value instead of blank.getRate, when the storedcustomUnitRateIDcan't be found in the resolved policy for a moved expense, fall back to the policy's default mileage rate rather than returning an empty rate.What alternative solutions did you explore? (Optional)
Investigation details & open questions
Important caveat (why this is medium, not high, confidence): Tracing the display code,
getRateForExpenseDisplay/getFormattedRateValuenormally return some string (Default rateoffline,Pendingonline, orRate out of policy) rather than a truly empty one. So either (a) the user perceives one of those placeholders as "blank", or (b) the blank comes from a more specific data inconsistency in the offline-moved transaction. Confirming the actual rendered string (vs. truly empty) from the repro video / runtime would tell us which.Write path evidence:
setMoneyRequestDistanceRate— writes the picked rate to the draft and nullsdefaultP2PRate.getRateID— returnsFAKE_P2P_IDwhen the rate is missing (so a missing rate should fall to P2P, not blank — supporting the "data inconsistency" theory).DistanceRequestControllerreconciliation.Display path evidence:
MoneyRequestViewrate resolution and the Rate menu item.useDistanceRateOriginalPolicyis only used for unreported expenses, so it doesn't help once the expense is moved to a workspace.Open questions for confirmation:
Pending/Rate out of policy/Default rate?customUnitRateIDat display time (offline)?customUnitIDmatching the destination policy's distance custom unit?Possibly related: #82960 — Merchant & Amount show "Scanning" when distance is submitted from self DM offline (same self-DM → workspace offline distance flow).
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/93575)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
KJ21-ENG commentedon Jun 15, 2026
Proposal
What is the root cause of that problem?
Distance-rate selection is stored on
transaction.comment.customUnit.customUnitRateID, but the offline submit-from-self-DM path does not consistently use the distance transaction item that is being converted when it builds the optimistic/API params.The tracked-expense submit flow starts by cloning the self-DM transaction into a draft, so the draft begins with the original self-DM/P2P rate. When the user selects the workspace rate on the confirmation page,
IOURequestStepDistanceRatewrites the selectedcustomUnitRateIDto the transaction draft.However,
useExpenseSubmissioncomputes onecustomUnitRateIDfrom the page-leveltransactionbefore iterating thetransactionscollection, then passes that same value into the conversion params for everyitem. The same hook already reads distance quantity from eachitembecause submit-from-self-DM can have a page-level transaction that has not inherited the distance custom unit, but it does not do the same for the rate ID.Offline, before the backend can reconcile anything, the converted workspace expense can keep
FAKE_P2P_IDor another stale rate ID instead of the selected workspace rate. The expense detail and Rate picker resolve rates from the workspace policy by storedcustomUnitRateID; a self-DM/P2P ID does not exist in that workspace rate map, so the Rate field opens blank even though the workspace has a default rate.What changes do you think we should make in order to solve the problem?
In
useExpenseSubmission, resolve the distancecustomUnitRateIDper submitteditembefore constructingtransactionParams.Concretely:
getRateID(item)instead of the page-level transaction rate.FAKE_P2P_IDor an empty rate while submitting to a policy expense chat, fall back through the same workspace selection rules used elsewhere: last selected distance rate for the policy, date-aware eligible rate, then policy default.requestMoney()loop fortransactionParams.customUnitRateID.trackExpense()loop for submit/categorize/share transaction params.createDistanceRequest()path using the single confirmationtransaction, since that path is not converting a separate list of tracked transaction items.This makes both the offline optimistic transaction and deferred API request carry the selected workspace rate immediately.
What alternative solutions did you explore? (Optional)
I considered fixing the Rate edit page to show a default option when the stored ID cannot be resolved, but that would only hide the bad optimistic data. The transaction and API payload would still carry the stale/P2P rate ID.
I also considered removing the moving-track guard in
DistanceRequestControllerthat skips auto-selecting a workspace rate while the draft is stillFAKE_P2P_ID, but that would change confirmation-page behavior and could silently override the tracked expense before the user chooses a workspace rate. The safer boundary is the final submit conversion, where we know the target policy and exact item being converted.Abdukhamid000 commentedon Jun 15, 2026
Proposal
What is the root cause of that problem?
When the user converts a tracked distance expense from self-DM into a real request, the optimistic transaction built on the client has no
customUnitRateID. The local view of the new expense therefore can't resolve a rate at render time —getRatefalls through toundefinedandrateToDisplayis blank. Online this is masked because the server response sends the canonical transaction back and overwrites the optimistic copy; offline the response is buffered indefinitely so the blank state is what the user sees.The trace:
[setCustomUnitRateID](https://github.com/Expensify/App/blob/main/src/libs/actions/IOU/MoneyRequest.ts#L1203-L1243)writescomment.customUnit.customUnitRateIDinto the draft transaction.[useExpenseSubmission.createDistanceRequest](https://github.com/Expensify/App/blob/main/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts#L543-L597), which readscustomUnitRateID = getRateID(transaction)from the draft and forwards it intransactionParams.requestMoney → getMoneyRequestInformationin[MoneyRequestBuilder.ts](https://github.com/Expensify/App/blob/main/src/libs/actions/IOU/MoneyRequestBuilder.ts#L1131-L1160). The destructuring there pulls outcustomUnit,distance,waypoints, etc. but notcustomUnitRateID:buildOptimisticTransactionis then called with that subset:https://github.com/Expensify/App/blob/main/src/libs/actions/IOU/MoneyRequestBuilder.ts#L1292-L1326
Since
customUnitisn't provided either (the convert-from-track caller only passescustomUnitRateID),buildOptimisticTransactionhits its else branch at[TransactionUtils/index.ts:506-514](https://github.com/Expensify/App/blob/main/src/libs/TransactionUtils/index.ts#L506-L514)and writescustomUnit.customUnitRateID = undefined:getRatein[MoneyRequestView](https://github.com/Expensify/App/blob/main/src/components/ReportActionItem/MoneyRequestView.tsx#L461)can't resolve arateName, and the Rate field renders empty.Online, the server's response carries the correct
customUnitRateIDand overwrites the optimistic transaction — the blank flashes for a moment and then resolves. Offline, the response is queued/buffered and the user is left looking at the blank state.What changes do you think we should make in order to solve the problem?
Thread
customUnitRateIDthrough the destructuring ingetMoneyRequestInformationand intobuildOptimisticTransactionso the optimistic transaction reflects the rate the user chose:const { attendees, amount, distance, modifiedAmount, comment = '', currency, source = '', created, merchant, receipt, category, tag, taxCode, taxAmount, taxValue, billable, reimbursable = true, linkedTrackedExpenseReportAction, pendingAction, pendingFields = {}, type, count, rate, unit, customUnit, + customUnitRateID, waypoints, odometerStart, odometerEnd, } = transactionParams;And forward it into the optimistic transaction:
let optimisticTransaction = buildOptimisticTransaction({ existingTransactionID: optimisticTransactionID, existingTransaction, ... transactionParams: { amount: isExpenseReport(iouReport) ? -amount : amount, distance, ... customUnit, + customUnitRateID, waypoints, odometerStart, odometerEnd, }, ... });buildOptimisticTransactionalready consumescustomUnitRateIDfrom its owntransactionParamsand writes it tocomment.customUnit.customUnitRateID(the else branch above), so no change is needed inTransactionUtils— only the plumbing between the two functions.The same fix lands behavior for the non-convert path: any caller that already passes
customUnitRateID(e.g. the regular distance-create flow) gets it propagated into the optimistic transaction instead of relying on the server response to backfill it. Offline rate display works in both flows after this change.The
existingTransactionbranch and split-expensecustomUnitbranch are untouched, so transactions that already carry a fullcustomUnit(split, edit) keep their current behavior.What alternative solutions did you explore?
setCustomUnitRateIDto also write the chosen rateID onto the committed transaction, not just the draft. Wrong layer — the committed transaction doesn't exist yet at confirmation-page time; what's missing is that the optimistic transaction the convert flow creates doesn't carry the rateID. Threading it through the builder is the change that's actually needed.customUnitobject in the convert-track caller and pass that through. Works but duplicates logic thatbuildOptimisticTransactionalready has for assembling the customUnit fromcustomUnitRateID,distance, anddistanceUnit. Passing the rateID is the smaller change.David-2002065 commentedon Jun 15, 2026
Proposal
What is the root cause of that problem?
When a tracked (self‑DM) distance expense is moved to a workspace while offline (
Submit it to someone), the optimistically‑moved expense's transaction thread report has nopolicyID— the self‑DM origin carries none, and the backend hasn't responded yet to populate it.On the Rate selection page,
IOURequestStepDistanceRateresolves the policy throughusePolicyForTransaction({reportPolicyID: report?.policyID}), which returnsreportPolicy ?? policyDraft. Sincereport?.policyIDis empty here,policyForTransactionisundefined, sopolicyisundefinedandgetMileageRates(policy, …)returns{}→ the rate list renders empty.The page already has a fallback that finds the owning policy by the transaction's
customUnitRateID, but it is gated behindisEditingSplit, so it never runs for this non‑split move flow.(The expense detail row still shows
Default RatebecauseMoneyRequestViewresolves the policy from the parent expense report'spolicyID, which is populated — not the thread report's.) Online, the backend returns the thread report with itspolicyID, so the lookup succeeds and the list isn't empty.What changes do you think we should make in order to solve the problem?
Broaden the existing rate‑ID policy fallback so it also runs when
policyForTransactionis missing — not only for splits. InIOURequestStepDistanceRate.tsx, change the guard ofpolicyByCustomUnitRateIDfromisEditingSplitto!policyForTransaction:The moved transaction still carries the selected workspace
customUnitRateID, so even with an emptyreport?.policyIDthis resolves the correct destination workspace andgetMileageRatesreturns its rates. The existing!isP2PRate/!== FAKE_P2P_IDguards keep genuine P2P expenses untouched, and whenpolicyForTransactionis present (the normal case) the fallback stays inert.For symmetry we can apply the same
!policyForTransactionguard topolicyByCustomUnitID(it already returnsundefinedfor this flow because the optimistic transaction has nocustomUnitIDoffline, but it keeps the two fallbacks consistent once the backend populatescustomUnitID).What alternative solutions did you explore? (Optional)
Populate the moved expense's transaction thread report
policyIDoptimistically insideconvertTrackedExpenseToRequestsousePolicyForTransactionresolves the policy directly, mirroring the data the backend returns online. This fixes the resolution at the source, but it edits the optimistic‑data builder and is broader/riskier than the display‑side change above; since the rate‑ID fallback already exists for the split case, extending it keeps the fix localized and pattern‑consistent.mukhrr commentedon Jun 15, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-07-06 04:06:11 UTC.
Proposal
What is the root cause of that problem?
There are two gaps in the optimistic data written when a self-DM tracked distance expense is submitted to a workspace, and both are only visible offline because the server response papers over them on reconnect.
Gap 1 — the blank rate picker (the reported symptom).
convertTrackedExpenseToRequestre-parents the existing self-DM transaction thread onto the workspace expense report, but the optimistic merge only writesparentReportActionID/parentReportID— never the destinationpolicyIDorchatReportID:App/src/libs/actions/IOU/TrackExpense.ts
Lines 1513 to 1533 in b8ad9b6
Tapping the Rate row navigates to
IOURequestStepDistanceRatewith that thread report, which resolves its policy purely fromreport?.policyID:App/src/pages/iou/request/step/IOURequestStepDistanceRate.tsx
Line 69 in b8ad9b6
App/src/hooks/usePolicyForTransaction.ts
Line 47 in b8ad9b6
A self-DM thread has no
policyID, so offline the policy isundefined,getMileageRates(undefined)returns{}, and the picker renders an empty list. The shape the server returns is whatbuildTransactionThreadalready documents — it setschatReportIDandpolicyIDalongside the parent fields:App/src/libs/ReportUtils.ts
Lines 8673 to 8679 in b8ad9b6
Gap 2 — the picked rate isn't kept. The rate selected on the confirm page is written to the draft and forwarded to the API as
customUnitRateID/customUnitID(viaworkspaceParams), but the optimistic transaction never receives it: the moved transaction keeps its stale self-DM custom unit until the server responds. So even with Gap 1 fixed, the picker lists the workspace rates without highlighting the one the user chose.What changes do you think we should make in order to solve the problem?
Fix both gaps inside
convertTrackedExpenseToRequest— the conversion boundary where the optimistic data diverges from the server response — so the optimistic state matches what the backend returns.1. Extend the thread re-parent merge with the destination
policyID/chatReportID, and restore the originals infailureData:optimisticData?.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`, value: { parentReportActionID: iouParams.reportActionID, parentReportID: iouParams.reportID, + chatReportID: iouParams.reportID, + policyID: workspaceParams?.policyID, }, }); failureData?.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`, value: { parentReportActionID: transactionThreadReport?.parentReportActionID, parentReportID: transactionThreadReport?.parentReportID, + chatReportID: transactionThreadReport?.chatReportID, + policyID: transactionThreadReport?.policyID, }, });workspaceParamsisundefinedfor a P2P "submit to an individual", so that path is untouched.2. In the
workspaceParamsbranch (the path that callsaddTrackedExpenseToPolicy), whenisDistance, apply the destination custom unit to the moved transaction optimistically, with afailureDatarollback:if (workspaceParams) { ... failureData?.push(...additionalFailureData); + if (isDistance) { + optimisticData?.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, + value: { + comment: { + customUnit: { + customUnitID: workspaceParams.customUnitID, + customUnitRateID, + defaultP2PRate: null, + }, + }, + }, + }); + + failureData?.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, + value: { + comment: { + customUnit: sourceTransaction?.comment?.customUnit ?? null, + }, + }, + }); + }Everything needed is already in scope in that function:
customUnitRateIDandisDistanceare destructured fromtransactionParams,sourceTransactionis already computed atApp/src/libs/actions/IOU/TrackExpense.ts
Line 1539 in b8ad9b6
App/src/libs/actions/IOU/MoneyRequestBuilder.ts
Line 1339 in b8ad9b6
SETof the transaction, so ordering is safe.With both in place the picker resolves the workspace policy, lists its rates, and pre-selects the picked rate offline — and the change is confined to the one action that creates the broken optimistic state.
What alternative solutions did you explore? (Optional)
n/a
ahmdshrif commentedon Jun 15, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
Moving a self-DM distance expense to a workspace ("Submit it to someone") offline and picking a rate on the confirm page leaves the Rate field blank when you reopen the expense. Expected: the selected rate.
What is the root cause of that problem?
The optimistic transaction for the moved expense is built from the stored self-DM (P2P) transaction, not the draft holding the rate the user just picked — so the selected
customUnitRateIDnever lands on it, and offline (no backend recompute) the rate can't resolve.setMoneyRequestDistanceRate:customUnit.customUnitRateID,defaultP2PRate:null).useExpenseSubmissionpasses the stored P2P transaction (not the draft) asexistingTransaction:App/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts
Line 475 in 7224b83
existingTransactionDraft:App/src/libs/actions/IOU/TrackExpense.ts
Line 1664 in 7224b83
MoneyRequestBuildernever forwards the pickedcustomUnitRateIDintobuildOptimisticTransaction, so the stored P2P customUnit wins thefastMerge(MoneyRequestBuilder#L1466).The new transaction stays
FAKE_P2P_ID;getRatethen takes the P2P branch (DistanceRequestUtils#L562-566) whose offline value is unresolved → blank.What changes do you think we should make in order to solve the problem?
Seed the optimistic transaction from the draft for the move flow: in
useExpenseSubmission, for SUBMIT passexistingTransactionDraft(orundefined) asexistingTransaction, sorequestMoney'saction === SUBMIT ? existingTransactionDraftbranch runs — the draft already carries the picked rate, unit anddefaultP2PRate:null. As a safeguard, also forwardcustomUnitRateIDthroughMoneyRequestBuilderintobuildOptimisticTransaction(already consumed there).Regression safety: only the move-from-self-DM optimistic base changes; normal workspace creation already passes the draft, so other flows are untouched.
What alternative solutions did you explore? (Optional)
getRateForP2P's offline fallback — incomplete: shows a P2P value, not the selected rate, and never fixes why a moved expense stays P2P.convertTrackedExpenseToRequestparams — fixes online/API, not the offline optimistic transaction.melvin-bot commentedon Jun 15, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @Krishna2323 (
External)x-dev90 commentedon Jun 15, 2026
Proposal
What is the root cause of that problem?
Clicking the Rate row from the submitted expense detail page navigates to
MONEY_REQUEST_STEP_DISTANCE_RATEwithtransactionThreadReport.reportIDas the routereportID:App/src/components/ReportActionItem/MoneyRequestView.tsx
Lines 849 to 855 in 2fa5241
In this offline submit-from-self-DM flow, the Rate step cannot rely on that route report to resolve the workspace policy.
IOURequestStepDistanceRatealready has fallback logic to find the policy from the transaction’scustomUnitIDorcustomUnitRateID, but that fallback is gated behindisEditingSplit:App/src/pages/iou/request/step/IOURequestStepDistanceRate.tsx
Lines 86 to 102 in 2fa5241
This issue is not a split edit. It is an edit of a submitted distance expense, so the fallback never runs. As a result,
policystays undefined,DistanceRequestUtils.getMileageRates(policy, false, currentRateID)returns no rates, and the Rate selector renders an empty list:App/src/pages/iou/request/step/IOURequestStepDistanceRate.tsx
Lines 123 to 153 in 2fa5241
What changes do you think we should make in order to solve the problem?
Allow the existing transaction-based policy fallback to run for any edited distance expense with a workspace rate, not only split edits.
Required changes:
isDistanceRequestbefore the fallback policy resolution.shouldResolvePolicyFromTransaction = isEditing && isDistanceRequest && !isP2PRate.policyByCustomUnitIDandpolicyByCustomUnitRateID.Tests that should be added:
IOURequestStepDistanceRatewhere the route report has no usable policy, the transaction has a workspacecustomUnitRateID, and the policy collection contains that rate. Verify the rate option is rendered and selected.FAKE_P2P_ID.I considered changing the optimistic distance transaction creation to always include
customUnitID, but the Rate step already supports resolving the policy bycustomUnitRateIDfor optimistic transactions. The missing piece is that this fallback is restricted to split edits, so widening the existing fallback to all edited distance expenses is the smaller root-cause fix.Demo
Video_2026-06-15_15-56-08.mp4
What alternative solutions did you explore? (Optional)
melvin-bot commentedon Jun 15, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022066475368910671811
83 remaining items
melvin-bot commentedon Aug 13, 2026
@Krishna2323 Whoops! This issue is 2 days overdue. Let's get this updated quick!
melvin-bot commentedon Aug 16, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Aug 16, 2026
Payment Summary
Resolving PRs:
Upwork Job
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Aug 18, 2026
Payment Summary
Contributor: @nabi-ebrahimi paid $250 via Upwork
Contributor+: @Krishna2323 due $250 via NewDot
@nabi-ebrahimi can you please accept the job below? Please reply here and tag me once you have.
https://www.upwork.com/jobs/~022089779867603282804
@Krishna2323 plz complete the BZ checklist and tag me in a post once you have. Thx
nabi-ebrahimi commentedon Aug 19, 2026
@mallenexpensify, Accepted the offer. thanks.
Krishna2323 commentedon Aug 19, 2026
BugZero Checklist:
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to the comment on the PR: Fix/79072 - Opening 1:1 expense in offline loads infinitely submitted from self dm #80213 (comment)
Link to the comment on the Issue: [Due for payment 2026-02-17] [$250] Expense - Opening 1:1 expense in offline loads infinitely submitted from self dm #79072 (comment)
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion:
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue: https://github.com/Expensify/Expensify/issues/673470
Regression Test Proposal
Precondition:
Test:
Do we agree 👍 or 👎
Zapier Logs
Run ID: 00040eee-60d7-a709-32f9-10215bc11ed4Krishna2323 commentedon Aug 19, 2026
@mallenexpensify checklist completed ^
mallenexpensify commentedon Aug 19, 2026
@nabi-ebrahimi paid, summary updated above. Thx.
^ Test case created. Thx
laurenreidexpensify commentedon Aug 26, 2026
$250 approved for @Krishna2323 New Expensify