Skip to content

[$250] Split distance - Error when creating new split with invalid waypoints offline #83538

Closed

Description

@mitarachim

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): sodnnisnjdisjndonsjo@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 map distance expense.
  4. Open the expense.
  5. Click More > Split > Save.
  6. Go offline.
  7. Open any split.
  8. Click Amount.
  9. Click Add split.
  10. Enter amount on the new split.
  11. Click on the new split.
  12. Click Distance.
  13. Edit both waypoints to invalid address (random address) > Save > Save.
  14. Click Save to create the new split.
  15. Go online.

Expected Result:

The new split will be created with "Please enter valid address" violation.

Actual Result:

The new split cannot be created. Error shows up on all three splits.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7088904_1772086687060.14.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022026914912690144254
  • Upwork Job ID: 2026914912690144254
  • 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.
    DeployBlockerIndicates it should block deploying the API
    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 @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 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: This is a new feature that does not exist in production (N/A)

    Recommendation: REVERT

    PR #82257 introduces the ability to handle distance and rate fields for split expenses. The bug occurs when creating a new split with invalid waypoints while offline - the error incorrectly displays on all three splits instead of only on the newly created split with invalid data. This suggests an issue with how violations/errors are being assigned or displayed for split transactions with invalid waypoint data.

    Labels: This is a frontend bug as the fix requires changes to Expensify/App. Both DeployBlockerCash and DeployBlocker labels are currently applied. Since this bug is:

    • Not reproducible in production (new feature)
    • Caused by an App PR that introduced distance split functionality
    • The fix requires reverting or patching the App PR

    The DeployBlocker label should be removed, keeping only DeployBlockerCash.

    Detailed Analysis

    Evidence

    Verification

    PR #82257 modifies multiple files related to split expense handling:

    • src/libs/actions/IOU/Split.ts - Core split logic with 326 additions
    • src/pages/iou/SplitExpenseEditPage.tsx - UI for editing splits
    • src/pages/iou/SplitExpensePage.tsx - Main split page flow
    • src/pages/iou/request/step/IOURequestStepDistanceMap.tsx - Distance map handling
    • src/pages/iou/request/step/IOURequestStepWaypoint.tsx - Waypoint editing
    • Multiple other distance-related components

    The PR introduces:

    • New OPTIMISTIC_DISTANCE_SPLIT_TRANSACTION_ID constant
    • New SPLIT_DRAFT transaction state
    • New GetRouteForSplitDraft API command
    • Extensive changes to handle waypoints, customUnit, and distance calculations in splits

    Root Cause

    When a new split is created with invalid waypoints (null island coordinates at lat: 0, lng: 0), the violation/error state is being incorrectly propagated to all splits in the group rather than being isolated to the specific split with invalid data. The code in SplitExpensePage.tsx shows error handling logic that checks for distance transactions (!isDistance conditions), but the violation assignment logic for individual splits with invalid waypoints appears to be missing proper scoping.

    The reproduction steps show that going offline, adding a split with invalid waypoints, then going online triggers the error on all splits - suggesting the error state is either:

    1. Being set on the parent transaction rather than the child split
    2. Not being properly filtered when displaying violations for each individual split
    3. Being optimistically applied to all splits during the offline→online sync
  7. 3 remaining items

  8. MelvinBot commented on Feb 26, 2026

    @MelvinBot
    Contributor

    Proposal

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

    When splitting a distance expense, going offline, adding a new split with invalid waypoints (random addresses), and then going back online, errors appear on all three splits instead of just the one with invalid waypoints. The new split cannot be created.

    What is the root cause of that problem?

    The updateSplitTransactions function in src/libs/actions/IOU/Split.ts accumulates failureData for all split transactions into a single shared onyxData object (lines 1115-1119, 1357-1359), then sends everything in one API.write(WRITE_COMMANDS.SPLIT_TRANSACTION, ...) call (line 1675).

    When the backend rejects this single API call (because one split has invalid waypoints), the Onyx update handler at src/libs/actions/OnyxUpdates.ts:54-74 applies all failureData entries as a batch. Since buildOnyxDataForMoneyRequest (in src/libs/actions/IOU/index.ts:2466-2473) adds a generic error (iou.error.genericCreateFailureMessage) to each split transaction's failureData entry, every split ends up with an error — not just the one with invalid waypoints.

    In short: the all-or-nothing nature of the single API call + batch failureData application means one bad split poisons the error state of all siblings.

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

    Add client-side waypoint validation in updateSplitTransactions (around src/libs/actions/IOU/Split.ts:1078-1089, where rate validation already exists) to check whether each split's waypoints are valid before making the API call. Specifically:

    1. In updateSplitTransactions, before the loop that builds onyxData, validate each split's waypoints using getValidWaypoints() from TransactionUtils. If a split has waypoints but none are valid (no lat/lng), set an error on only that split's draft transaction and return early without calling the API.
    2. This mirrors how rate validation is already handled at lines 1078-1089 of Split.ts — checking for valid data before proceeding with the API call.

    This prevents the scenario where invalid waypoints are sent to the backend, which would reject the entire batch and propagate errors to all splits.

    What alternative solutions did you explore? (Optional)

    • Modify failureData to be per-split: Instead of setting errors on all transactions in failureData, only set errors on the parent/original transaction. This is more invasive and could miss other failure scenarios.
    • Split into multiple API calls: Send each split as a separate API call so failures are isolated. This would be a larger architectural change and could introduce consistency issues.
    • Add per-split error display in SplitListItem: While useful for UX, this alone doesn't solve the root problem of all splits being marked as errored.

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

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

    @melvin-bot

    Current assignees @suneox and @ZhenjaHorbach are eligible for the External assigner, not assigning anyone new.

  12. changed the title [-]Split distance - Error when creating new split with invalid waypoints offline[/-] [+][$250] Split distance - Error when creating new split with invalid waypoints offline[/+] on Feb 26, 2026
  13. melvin-bot commented on Feb 26, 2026

    @melvin-bot
  14. jainam884 commented on Feb 26, 2026

    @jainam884

    Proposal

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

    When one newly added split has invalid waypoints offline, going online causes failure state/errors to appear across all sibling splits instead of only the invalid one.

    What is the root cause of that problem?

    updateSplitTransactions builds one shared onyxData object and accumulates failure entries from each split into that single request payload, then sends one SPLIT_TRANSACTION write. On non-200, Onyx applies the entire request failureData set, so sibling splits inherit failure state.

    },
    transactionParams: {
    amount: Math.abs(originalTransaction?.amount ?? 0),
    modifiedAmount: splitExpense.amount ?? 0,
    currency: originalTransactionDetails?.currency ?? CONST.CURRENCY.USD,

    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT}${firstIOU?.childReportID}`,
    value: transactionThread ?? null,

    if (response.jsonCode === 200 && request.successData) {
    return updateHandler(request.successData);
    }
    if (response.jsonCode !== 200 && request.failureData) {
    // 460 jsonCode in Expensify world means "admin required".
    // Typically, this would only happen if a user attempts an API command that requires policy admin access when they aren't an admin.
    // In this case, we don't want to apply failureData because it will likely result in a RedBrickRoad error on a policy field which is not accessible.
    // Meaning that there's a red dot you can't dismiss.
    if (response.jsonCode === 460) {
    Log.info('[OnyxUpdateManager] Received 460 status code, not applying failure data');
    return Promise.resolve();
    }
    return updateHandler(request.failureData);
    }
    return Promise.resolve();
    })
    .then(() => {
    if (request.finallyData) {

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

    Isolate failure scope by request, not by post-failure UI filtering:

    1. For split-creation path, send per-split API writes (or per-split failure buckets) instead of one shared batch failure payload.
    2. Apply failureData only for the split request that actually fails, leaving sibling split transactions untouched.
    3. Keep report-total reconciliation after all split requests finish, so totals remain consistent without broad error fan-out.

    This removes the “one bad split poisons all siblings” failure mode directly.

    What alternative solutions did you explore? (Optional)

    Client-side pre-validation of waypoints is simpler, but it does not fully solve backend or sync-time single-request failure fan-out patterns.

  15. suneox commented on Feb 26, 2026

    @suneox
    Contributor

    When UpdateSplitTransaction BE also doesn't store a valid value at 0:46 response at 1:20 and we need also handle on BE side or show error for batch expense also make sense

    83538.1.mp4
  16. puneetlath commented on Feb 26, 2026

    @puneetlath
    Contributor

    Demoting as BE issue. cc @lakchote

  17. lakchote commented on Feb 27, 2026

    @lakchote
    Contributor
  18. garrettmknight commented on Mar 17, 2026

    @garrettmknight
    Contributor

    Fixed, no C+ reviewer, closing.

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 contributorsHourlyKSv2ReviewingHas a PR in review

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions