Skip to content

[$250] Distance - "Please fix the distance rate error" appears when approved split cannot be edited #83564

Closed

Description

@jponikarchuk

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.3.26-4
Reproducible in staging?: Yes
Reproducible in production?: N/A - new feature, doesn't exist in prod
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #82257
Email or phone of affected tester (no customers): jsdoijsoidnjoisjdsoi@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.2 / Chrome
App Component: Money Requests

Action Performed:

Precondition:

  • Distance rates are enabled.
  • Workspace has two distance rates.
  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Create a manual distance expense.
  4. Open the expense.
  5. Click More > Split > Save.
  6. Open any split.
  7. Click Report > Create report.
  8. On the current report, click Submit and Approve.
  9. Go to workspace settings > Distance rates.
  10. Delete the distance rate used in Step 3.
  11. Open the expense report containing split in the new report (from Step 7).
  12. Click Amount.
  13. Click on the highlighted row.
  14. Click Rate > select other rate > Save.
  15. Click Save.

Expected Result:

User should be able to save the split because user has changed the split rate to valid rate in Step 14.

Actual Result:

"Please fix the distance rate error" shows up, but user cannot edit the approved split (from 8).

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @abzokhattab
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022026997105019388034
  • Upwork Job ID: 2026997105019388034
  • Last Price Increase: 2026-02-26

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Feb 26, 2026
  2. melvin-bot commented on Feb 26, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #82257

  3. melvin-bot commented on Feb 26, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  4. melvin-bot commented on Feb 26, 2026

    @melvin-bot

    Triggered auto assignment to @laurenreidexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  5. github-actions commented on Feb 26, 2026

    @github-actions
    Contributor

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

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  6. OSBotify commented on Feb 26, 2026

    @OSBotify
    Contributor

    🔍 Investigation Summary

    Classification: Frontend bug
    Causing PR: #82257 - "feat: handle the Distance and Rate fields for splits" by @ZhenjaHorbach (High confidence)
    Related Issues: None

    Recommendation: REVERT

    PR #82257 introduced validation logic that prevents saving distance splits with invalid rate IDs. However, this validation does not account for approved splits that cannot be edited. When a distance rate is deleted after a split is approved, users are trapped in an impossible state where they cannot save changes even after selecting a valid rate.

    Labels: Keeping DeployBlockerCash label (frontend bug in App repo)

    📋 Detailed Analysis

    Evidence

    PR #82257 added distance rate validation to SplitExpensePage.tsx (lines 152-166 and 204-212 in the current code):

    let isUnitRateIDOutOfPolicy = false;
    for (const splitExpense of splitExpenses) {
        const splitTransaction = allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${getNonEmptyStringOnyxID(splitExpense.transactionID)}`] ?? transaction;
        if (splitTransaction && currentPolicy) {
            const isSplitDistance = isDistanceRequest(splitTransaction);
            if (isSplitDistance) {
                const currentRateID = splitExpense?.customUnit?.customUnitRateID ?? String(CONST.DEFAULT_NUMBER_ID);
                const rates = DistanceRequestUtils.getMileageRates(currentPolicy, false, currentRateID);
                const {rate} = DistanceRequestUtils.getRate({transaction: splitTransaction, policy: currentPolicy});
                if (!rates[currentRateID] || !rate) {
                    isUnitRateIDOutOfPolicy = true;
                }
            }
        }
    }

    And blocks saving in the onSaveSplitExpense handler:

    if (isUnitRateIDOutOfPolicy) {
        showConfirmModal({
            title: translate('iou.splitExpense'),
            prompt: translate('iou.splitExpenseDistanceErrorModalDescription'),
            confirmText: translate('common.buttonConfirm'),
            shouldShowCancelButton: false,
        });
        return;
    }

    Verification

    Root Cause

    The validation logic checks if the rate ID exists in the policy's current rates, but it does not consider that:

    1. After Step 8 (Submit and Approve), the split expense report becomes approved
    2. Approved splits cannot be edited (per isSplitAction logic in ReportSecondaryActionUtils.ts lines 137-139, which blocks editing when report.statusNum >= CONST.REPORT.STATUS_NUM.CLOSED)
    3. When the user tries to change the rate in Step 14, they are editing an approved split
    4. The validation runs before save and blocks with "Please fix the distance rate error"
    5. The user cannot actually fix it because the split is approved and cannot be saved

    This creates an impossible user state where the error message says to fix the rate, but the system prevents saving any changes.

  7. MelvinBot commented on Feb 26, 2026

    @MelvinBot
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When a distance expense is split and one of the splits is moved to a report that gets approved, then the original distance rate is deleted from the workspace, the user is blocked from saving any changes to the remaining editable splits. The error "Please fix the distance rate error" appears, but the user cannot fix it because the approved split (which still references the deleted rate) cannot be edited.

    What is the root cause of that problem?

    The distance rate validation loop in SplitExpensePage.tsx (lines 152-166) checks all split expenses unconditionally — it does not filter out non-editable (approved/settled/closed) splits:

    let isUnitRateIDOutOfPolicy = false;
    for (const splitExpense of splitExpenses) {
        // No editability check — iterates ALL splits
        ...
        if (!rates[currentRateID] || !rate) {
            isUnitRateIDOutOfPolicy = true;
        }
    }

    When isUnitRateIDOutOfPolicy is true, the save is blocked at lines 204-212 with a modal error.

    Meanwhile, the editability check at lines 357-359 uses isSplitAction() from ReportSecondaryActionUtils.ts (line 137-139), which returns false for reports with statusNum >= CLOSED (includes APPROVED=3). Non-editable splits show a "cannot be edited" modal at lines 456-465.

    This creates a deadlock: the validation fails because an approved split references a deleted rate, but the user cannot fix the approved split because it's non-editable.

    What changes do you think we should make in order to solve the problem?

    Modify the validation loop in SplitExpensePage.tsx (lines 152-166) to skip non-editable splits when checking for invalid distance rates. The loop should compute the editability of each split (using the same isSplitAction logic already used at line 357-359) and only set isUnitRateIDOutOfPolicy = true for splits the user can actually edit.

    This way, if an approved split has a deleted rate but the user has already fixed all editable splits, the save will proceed without being blocked by issues the user cannot resolve.

    What alternative solutions did you explore? (Optional)

    1. Auto-update the rate on non-editable splits during save — This would silently change data on approved transactions, which could cause accounting issues.
    2. Show a warning instead of blocking — This would let the user save but might propagate invalid rate data, so filtering the validation to only editable splits is cleaner.

    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

  8. 5 remaining items

  9. melvin-bot commented on Feb 26, 2026

    @melvin-bot
  10. ZhenjaHorbach commented on Feb 26, 2026

    @ZhenjaHorbach
    Contributor

    I will create a fix soon

  11. removed
    Help WantedApply this label when an issue is open to proposals by contributors
    on Feb 26, 2026
  12. suneox commented on Feb 26, 2026

    @suneox
    Contributor

    This issue also occurs on the latest production build v9.3.25-13, so I think we can separate this into a new issue cause saved new expense with invalid rate also show error

    83564.1.mp4
  13. m-natarajan commented on Feb 26, 2026

    @m-natarajan

    Able to save the split but Rate not valid for this workspace error message displayed, Windows 10/ Chrome, v9.3.26-6

    repro.-.issue.83564.mp4
  14. lakchote commented on Mar 17, 2026

    @lakchote
    Contributor

    Issue not reproducible:

    Screen.Recording.2026-03-17.at.07.39.17.mov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.EngineeringExternalAdded to denote the issue can be worked on by a contributorHourlyKSv2ReviewingHas a PR in review

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions