Skip to content

[Due for payment 2026-08-17] [$250] Distance - Rate field is blank when distance is submitted from self DM offline #93575

Closed

Description

@izarutskaya

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


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:

  1. Go to staging.new.expensify.com
  2. Create two workspaces.
  3. Go to workspace settings of the second workspace > More features.
  4. Enable Distance rates.
  5. Go to Distance rates.
  6. Click Settings > Unit.
  7. Change to another unit (Kilometers if Miles is the default rate).
  8. Go to self DM.
  9. Create a distance expense.
  10. Go offline.
  11. Click Submit it to someone.
  12. Select the second workspace chat with modified distance unit.
  13. On confirm page, click Rate and select default rate.
  14. Click Create expense.
  15. Open the distance expense.
  16. 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.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Bug7159822_1779379514021.3.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jun 15, 2026
  2. MelvinBot commented on Jun 15, 2026

    @MelvinBot
    Contributor

    Proposal

    ⚠️ 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.

    Write path evidence:

    Display path evidence:

    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.

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jun 15, 2026
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jun 15, 2026
  5. KJ21-ENG commented on Jun 15, 2026

    @KJ21-ENG
    Contributor

    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.

  6. Abdukhamid000 commented on Jun 15, 2026

    @Abdukhamid000
    Contributor

    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 — 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.

    The trace:

    1. On the confirmation page the user picks a rate. [setCustomUnitRateID](https://github.com/Expensify/App/blob/main/src/libs/actions/IOU/MoneyRequest.ts#L1203-L1243) writes comment.customUnit.customUnitRateID into the draft transaction.
    2. The "Create" tap routes through [useExpenseSubmission.createDistanceRequest](https://github.com/Expensify/App/blob/main/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts#L543-L597), which reads customUnitRateID = getRateID(transaction) from the draft and forwards it in transactionParams.
    3. That flows into requestMoney → getMoneyRequestInformation in [MoneyRequestBuilder.ts](https://github.com/Expensify/App/blob/main/src/libs/actions/IOU/MoneyRequestBuilder.ts#L1131-L1160). The destructuring there pulls out customUnit, distance, waypoints, etc. but not customUnitRateID:
    const {
        attendees, amount, distance, ..., customUnit, waypoints, odometerStart, odometerEnd,
    } = transactionParams;
    1. buildOptimisticTransaction is then called with that subset:

    https://github.com/Expensify/App/blob/main/src/libs/actions/IOU/MoneyRequestBuilder.ts#L1292-L1326

    Since customUnit isn't provided either (the convert-from-track caller only passes customUnitRateID), buildOptimisticTransaction hits its else branch at [TransactionUtils/index.ts:506-514](https://github.com/Expensify/App/blob/main/src/libs/TransactionUtils/index.ts#L506-L514) and writes customUnit.customUnitRateID = undefined:

    if (customUnit) {
        lodashSet(commentJSON, 'customUnit', customUnit);
    } else {
        lodashSet(commentJSON, 'customUnit.distanceUnit', ...);
        lodashSet(commentJSON, 'customUnit.quantity', distance);
        lodashSet(commentJSON, 'customUnit.customUnitRateID', customUnitRateID); // ← undefined here
        lodashSet(commentJSON, 'customUnit.name', ...);
    }
    1. The optimistic transaction lands in Onyx with no rateID. getRate in [MoneyRequestView](https://github.com/Expensify/App/blob/main/src/components/ReportActionItem/MoneyRequestView.tsx#L461) can't resolve a rateName, and the Rate field renders empty.

    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:

     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,
         },
         ...
     });

    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.
  7. David-2002065 commented on Jun 15, 2026

    @David-2002065
    Contributor

    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 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:

    const policyByCustomUnitRateID =
        !policyForTransaction && !policyByCustomUnitID && distanceCustomUnitRateID && distanceCustomUnitRateID !== CONST.CUSTOM_UNITS.FAKE_P2P_ID
            ? (Object.values(allPolicies ?? {}).find((p) => Object.values(p?.customUnits ?? {}).some((unit) => !!unit.rates?.[distanceCustomUnitRateID])) ?? undefined)
            : undefined;

    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.

  8. mukhrr commented on Jun 15, 2026

    @mukhrr
    Contributor

    🚨 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:

    if (transactionThreadReportID) {
    const transactionThreadReport = getReportOrDraftReport(transactionThreadReportID);
    optimisticData?.push({
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`,
    value: {
    parentReportActionID: iouParams.reportActionID,
    parentReportID: iouParams.reportID,
    },
    });
    failureData?.push({
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`,
    value: {
    parentReportActionID: transactionThreadReport?.parentReportActionID,
    parentReportID: transactionThreadReport?.parentReportID,
    },
    });
    }

    Tapping the Rate row navigates to IOURequestStepDistanceRate with that thread report, which resolves its policy purely from report?.policyID:

    const {policy: policyForTransaction} = usePolicyForTransaction({transaction, reportPolicyID: report?.policyID, action, iouType, policyDraft});

    const policy = isUnreportedExpense || isCreatingTrackExpense ? policyForSelfDMExpense : (reportPolicy ?? policyDraft);

    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:

    App/src/libs/ReportUtils.ts

    Lines 8673 to 8679 in b8ad9b6

    policyID: moneyRequestReport?.policyID,
    ownerAccountID: CONST.POLICY.OWNER_ACCOUNT_ID_FAKE,
    notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
    parentReportActionID: reportAction?.reportActionID,
    parentReportID: moneyRequestReport?.reportID,
    optimisticReportID: optimisticTransactionThreadReportID,
    chatReportID: moneyRequestReport?.reportID,

    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:

        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,
            },
        });

    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:

        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: customUnitRateID and isDistance are destructured from transactionParams, sourceTransaction is already computed at

    const sourceTransaction = getAllTransactions()?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`];
    , and the conversion reuses the original transaction ID (
    const optimisticTransactionID = existingTransactionID ?? providedOptimisticTransactionID ?? rand64();
    ), 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)

    n/a

  9. ahmdshrif commented on Jun 15, 2026

    @ahmdshrif
    Contributor

    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 customUnitRateID never lands on it, and offline (no backend recompute) the rate can't resolve.

    1. Picking the rate writes it to the draft (setMoneyRequestDistanceRate: customUnit.customUnitRateID, defaultP2PRate:null).
    2. On submit, useExpenseSubmission passes the stored P2P transaction (not the draft) as existingTransaction:
      existingTransaction: existingTransaction ?? item,
    3. That non-null value short-circuits the SUBMIT branch meant to use existingTransactionDraft:
      explicitExistingTransaction ?? (action === CONST.IOU.ACTION.SUBMIT ? existingTransactionDraft : getAllTransactions()[`${ONYXKEYS.COLLECTION.TRANSACTION}${existingTransactionID}`]);
    4. 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.
  10. melvin-bot commented on Jun 15, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @Krishna2323 (External)

  11. x-dev90 commented on Jun 15, 2026

    @x-dev90

    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_RATE with transactionThreadReport.reportID as the route reportID:

    Navigation.navigate(
    ROUTES.MONEY_REQUEST_STEP_DISTANCE_RATE.getRoute(
    CONST.IOU.ACTION.EDIT,
    iouType,
    transaction.transactionID,
    transactionThreadReport.reportID,
    getReportRHPActiveRoute(),

    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:

    // When editing a distance split from self-DM, policyForTransaction may be undefined because the self-DM
    // report has no policyID. In that case, find the correct policy by searching for the one that contains
    // the transaction's customUnitID. If customUnitID is not available (e.g. optimistic transaction before
    // server response), fall back to searching by customUnitRateID.
    // Skip both lookups when the rate is P2P — the expense has no workspace policy to resolve.
    const distanceCustomUnitID = currentTransaction?.comment?.customUnit?.customUnitID;
    const distanceCustomUnitRateID = currentTransaction?.comment?.customUnit?.customUnitRateID;
    const isP2PRate = distanceCustomUnitRateID === CONST.CUSTOM_UNITS.FAKE_P2P_ID;
    const policyByCustomUnitID =
    isEditingSplit && !isP2PRate && distanceCustomUnitID ? (Object.values(allPolicies ?? {}).find((p) => p?.customUnits?.[distanceCustomUnitID]) ?? undefined) : undefined;
    const policyByCustomUnitRateID =
    isEditingSplit && !policyByCustomUnitID && distanceCustomUnitRateID && distanceCustomUnitRateID !== CONST.CUSTOM_UNITS.FAKE_P2P_ID
    ? (Object.values(allPolicies ?? {}).find((p) => Object.values(p?.customUnits ?? {}).some((unit) => !!unit.rates?.[distanceCustomUnitRateID])) ?? undefined)
    : undefined;
    const availablePaidPolicies = isEditingSplit ? getGroupPaidPoliciesWithExpenseChatEnabled(allPolicies ?? {}) : [];
    const fallbackAvailablePolicy = isEditingSplit && !isP2PRate && !policyForTransaction && !policyByCustomUnitID && !policyByCustomUnitRateID ? availablePaidPolicies.at(0) : undefined;
    const policy = policyForTransaction ?? policyByCustomUnitID ?? policyByCustomUnitRateID ?? fallbackAvailablePolicy;

    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:

    const rates = DistanceRequestUtils.getMileageRates(policy, false, currentRateID);
    const isMovingTransactionFromTrackExpense = isMovingTransactionFromTrackExpenseUtil(action);
    const transactionUnit = transaction?.comment?.customUnit?.distanceUnit;
    const sortedRates = [...Object.values(rates)].sort((a, b) => localeCompare(a.name ?? '', b.name ?? ''));
    const navigateBack = () => {
    Navigation.goBack(backTo);
    };
    const options = sortedRates.map((rate) => {
    const hasUnitMismatchForMovingTrackExpense = isMovingTransactionFromTrackExpense && transactionUnit !== rate.unit;
    const unit =
    currentTransaction?.comment?.customUnit?.customUnitRateID === rate.customUnitRateID && !hasUnitMismatchForMovingTrackExpense
    ? DistanceRequestUtils.getDistanceUnit(currentTransaction, rate)
    : rate.unit;
    const effectiveRateID = pendingRateID ?? currentRateID;
    const isSelected = effectiveRateID
    ? effectiveRateID === rate.customUnitRateID && !hasUnitMismatchForMovingTrackExpense
    : DistanceRequestUtils.getDefaultMileageRate(policy)?.customUnitRateID === rate.customUnitRateID;
    const rateForDisplay = DistanceRequestUtils.getFormattedRateValue(unit, rate.rate, isSelected ? transactionCurrency : rate.currency, translate, toLocaleDigit, getCurrencySymbol);
    const dateLabel = DistanceRequestUtils.getRateDateLabel(rate, translate);
    const alternateText = [rate.name ? rateForDisplay : '', dateLabel].filter(Boolean).join(' • ');
    return {
    text: rate.name ?? rateForDisplay,
    alternateText,
    keyForList: rate.customUnitRateID ?? rateForDisplay,
    value: rate.customUnitRateID,
    isDisabled: !rate.enabled,
    isSelected,
    };
    });

    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:

    • Move isDistanceRequest before the fallback policy resolution.
    • Add shouldResolvePolicyFromTransaction = isEditing && isDistanceRequest && !isP2PRate.
    • 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)

  12. melvin-bot commented on Jun 15, 2026

    @melvin-bot
  13. 83 remaining items

  14. melvin-bot commented on Aug 13, 2026

    @melvin-bot

    @Krishna2323 Whoops! This issue is 2 days overdue. Let's get this updated quick!

  15. melvin-bot commented on Aug 16, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  16. melvin-bot commented on Aug 16, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
  17. mallenexpensify commented on Aug 18, 2026

    @mallenexpensify
    Contributor

    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

  18. nabi-ebrahimi commented on Aug 19, 2026

    @nabi-ebrahimi

    @mallenexpensify, Accepted the offer. thanks.

  19. Krishna2323 commented on Aug 19, 2026

    @Krishna2323
    Contributor

    BugZero Checklist:

    Regression Test Proposal

    Precondition:

    Test:

    1. Sign in.
    2. Create two workspaces.
    3. Go to the second workspace settings > More features.
    4. Enable Distance rates.
    5. Go to Distance rates.
    6. Open Settings > Unit.
    7. Change the unit to another unit, for example Kilometers if Miles is the default.
    8. Go to self DM.
    9. Create a distance expense.
    10. Go offline.
    11. Click Submit it to someone.
    12. Select the second workspace chat.
    13. On the confirm page, click Rate and select the default rate.
    14. Click Create expense.
    15. Open the created distance expense.
    16. Click the Rate field.
    17. Verify the Rate page is populated and the selected rate is shown.
    18. Verify the selected rate uses the workspace distance unit.

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-60d7-a709-32f9-10215bc11ed4
  20. Krishna2323 commented on Aug 19, 2026

    @Krishna2323
    Contributor

    @mallenexpensify checklist completed ^

  21. mallenexpensify commented on Aug 19, 2026

    @mallenexpensify
    Contributor

    @nabi-ebrahimi paid, summary updated above. Thx.

    ^ Test case created. Thx

  22. laurenreidexpensify commented on Aug 26, 2026

    @laurenreidexpensify
    Contributor

    $250 approved for @Krishna2323 New Expensify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions