Skip to content

[$250] Distance - Split amounts do not auto redistribute when adding distance split #83690

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-8
Reproducible in staging?: Yes
Reproducible in production?: No
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): osidnjodjosijsoji@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:

  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Create a manual expense.
  4. Open the expense.
  5. Click More > Split.
  6. Click Add split.
    → All split amounts auto redistribute.
  7. Create a manual distance expense.
  8. Open the expense.
  9. Click More > Split.
  10. Click Add split.

Expected Result:

Split amounts will auto redistribute when adding distance split.

Actual Result:

Split amounts do not auto redistribute when adding distance split.

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: @jjcoffee
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022027384280847457211
  • Upwork Job ID: 2027384280847457211
  • Last Price Increase: 2026-02-27

Activity

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

    @melvin-bot

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

  3. melvin-bot commented on Feb 27, 2026

    @melvin-bot

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

  4. melvin-bot commented on Feb 27, 2026

    @melvin-bot

    Triggered auto assignment to @sonialiap (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 27, 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 27, 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 should be reverted. The PR introduced inconsistent behavior between manual and distance expense splits. When adding a new split to a manual expense, amounts auto-redistribute across all splits. However, for distance expenses, this auto-redistribution was intentionally disabled, creating a confusing user experience.

    Labels: No changes needed. Keeping DeployBlockerCash (frontend bug blocking App deploy). This issue is not reproducible on production, confirming it was introduced by a PR currently on staging.

    Detailed Analysis

    Evidence

    The issue states that split amounts auto-redistribute when adding a split to a manual expense, but NOT when adding a split to a distance expense. This inconsistency was introduced by PR #82257.

    Verification

    In /home/runner/_work/App/App/src/libs/actions/IOU/Split.ts, the addSplitExpenseField function at lines 2091-2094 contains this logic:

    // Auto-redistribute amounts for all splits if this is not a distance request
    if (!isDistanceRequest) {
        redistributedSplitExpenses = redistributeSplitExpenseAmounts(updatedSplitExpenses, total, currency);
    }

    This condition explicitly skips auto-redistribution for distance requests. The comment indicates this was intentional, but it creates an inconsistent user experience where:

    • Manual expense: Click "Add split" and amounts redistribute automatically
    • Distance expense: Click "Add split" and amounts do NOT redistribute

    Root Cause

    PR #82257 added comprehensive support for distance and rate fields in splits. As part of this work, the author intentionally disabled auto-redistribution for distance expenses (line 2092), likely because distance splits have additional complexity with distance/rate calculations. However, this created a UX inconsistency that users find confusing.

    The PR modified 25 files including:

    • /home/runner/_work/App/App/src/libs/actions/IOU/Split.ts (added redistribution skip logic)
    • /home/runner/_work/App/App/src/pages/iou/SplitExpensePage.tsx
    • Multiple distance request step files

    Why Revert?

    While the PR added valuable functionality for distance splits, the inconsistent behavior is confusing and blocks deployment. A revert allows time to properly address the UX inconsistency - either by enabling auto-redistribution for distance splits or by disabling it for all split types to maintain consistency.

  7. MelvinBot commented on Feb 27, 2026

    @MelvinBot
    Contributor

    Proposal

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

    When splitting a distance expense and clicking "Add split", the split amounts do not auto-redistribute. The new split is added with amount $0.00 and the existing splits keep their original amounts. This works correctly for manual expenses.

    What is the root cause of that problem?

    In src/libs/actions/IOU/Split.ts, the addSplitExpenseField function (which handles the "Add split" button) has an explicit if (!isDistanceRequest) guard at line 2092 that skips calling redistributeSplitExpenseAmounts for distance expenses:

    let redistributedSplitExpenses = updatedSplitExpenses;
    // Auto-redistribute amounts for all splits if this is not a distance request
    if (!isDistanceRequest) {
        redistributedSplitExpenses = redistributeSplitExpenseAmounts(updatedSplitExpenses, total, currency);
    }
    

    This means the newly added split stays at amount=0 with distance quantity=0, and existing splits are not rebalanced. The same guard exists in two other functions:

    • removeSplitExpenseField at line 2259 (removing a split)
    • updateSplitExpenseAmountField at line 2418 (editing a split's amount)

    Notably, evenlyDistributeSplitExpenseAmounts at line 2113 (the "Make splits even" button) does not have this guard and correctly handles distance expenses — it redistributes amounts, then recalculates each split's distance and merchant via updateSplitExpenseDistanceFromAmount.

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

    In src/libs/actions/IOU/Split.ts, for each of the three affected functions (addSplitExpenseField, removeSplitExpenseField, updateSplitExpenseAmountField):

    1. Remove the if (!isDistanceRequest) guard so redistributeSplitExpenseAmounts is called for all expense types
    2. After redistribution, add distance-field recalculation for distance expenses — iterate over the redistributed splits and call updateSplitExpenseDistanceFromAmount to derive the correct customUnit.quantity and merchant from the new amount, following the exact pattern already implemented in evenlyDistributeSplitExpenseAmounts (lines 2148-2159)

    What alternative solutions did you explore? (Optional)

    An alternative would be to extend redistributeSplitExpenseAmounts itself to handle distance fields internally. However, that function is a pure amount-redistribution utility and adding distance awareness would mix concerns. The approach of keeping redistribution and distance-field recalculation as separate steps (as evenlyDistributeSplitExpenseAmounts already does) is cleaner and more consistent with the existing codebase patterns.


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

  8. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Feb 27, 2026
  9. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Feb 27, 2026
  10. melvin-bot commented on Feb 27, 2026

    @melvin-bot

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

  11. changed the title [-]Distance - Split amounts do not auto redistribute when adding distance split[/-] [+][$250] Distance - Split amounts do not auto redistribute when adding distance split[/+] on Feb 27, 2026
  12. melvin-bot commented on Feb 27, 2026

    @melvin-bot
  13. puneetlath commented on Feb 27, 2026

    @puneetlath
    Contributor
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 contributorHelp WantedApply this label when an issue is open to proposals by contributorsHourlyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions