Skip to content

[Due for payment 2026-01-28] [$250] Expense - Split status is removed after editing split, error after editing second split #78933

Closed

Description

@lanitochka17

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.2.94-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #77911
Email or phone of affected tester (no customers): sdosdjnnosijsnoij@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.1 / Chrome
App Component: Money Requests

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Create an expense.
  4. Open expense report.
  5. Click More > Split > Save.
  6. Click More > Delete > Delete the report.
  7. Go to self DM.
  8. Open any split.
  9. Click Report > Create report.
  10. Click Amount.
    → Edit splits page opens.
  11. Edit the amount and save it.
  12. Click Amount field again.
    BUG 1: Split status is removed. Amount editor opens instead of Edit splits page.
  13. Go to self DM.
  14. Open the remaining split.
  15. Click Report > Select the report in Step 9.
  16. Click Amount.
  17. Edit the amount and save it.
    BUG 2: "Unexpected error deleting this expense. Please try again later.The specified transaction is not one of the split transactions" error shows up.

Expected Result:

BUG 1: Split status should persist after editing the split amount. Edit splits page should open after editing the split amount.
BUG 2: No error should show up after editing the second split amount.

Actual Result:

BUG 1: Split status is removed. Amount editor opens instead of Edit splits page.
BUG 2: "Unexpected error deleting this expense. Please try again later.The specified transaction is not one of the split transactions" error shows up.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7042259_1767716782562.7.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022008645763042389985
  • Upwork Job ID: 2008645763042389985
  • Last Price Increase: 2026-01-06
  • Automatic offers:
    • MobileMage | Contributor | 110038222
Issue OwnerCurrent Issue Owner: @JmillsExpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jan 6, 2026
  2. melvin-bot commented on Jan 6, 2026

    @melvin-bot

    Triggered auto assignment to @JmillsExpensify (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.

  3. MobileMage commented on Jan 6, 2026

    @MobileMage
    Contributor

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

    Two bugs:

    1. BUG 1: After editing a split expense amount, the split status is removed - clicking Amount field opens Amount editor instead of Edit splits page.
    2. BUG 2: When editing the second split after moving it to the same report, an error appears: "Unexpected error deleting this expense. Please try again later. The specified transaction is not one of the split transactions"

    What is the root cause of that problem?

    The root cause is in getChildTransactions in src/libs/TransactionUtils/index.ts:2367-2375:

    function getChildTransactions(transactions: OnyxCollection<Transaction>, reports: OnyxCollection<Report>, originalTransactionID: string | undefined) {
        return Object.values(transactions ?? {}).filter((currentTransaction) => {
            const currentReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${currentTransaction?.reportID}`];
            return (
                currentTransaction?.comment?.originalTransactionID === originalTransactionID &&
                !!currentReport &&  // <-- ISSUE: Requires report to exist
                currentTransaction?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE
            );
        });
    }

    The function requires !!currentReport - the transaction's report must exist. When a report is deleted, child transactions that still reference the deleted report cannot be found.

    In updateSplitTransactions (src/libs/actions/IOU/index.ts:14393):

    const isReverseSplitOperation = splitExpenses.length === 1 && originalChildTransactions.length > 0 && hasEditableSplitExpensesLeft;

    Since only 1 child was found, isReverseSplitOperation = true, triggering a "revert to single expense" operation.

    When isReverseSplitOperation is true (lines 14497-14513), the transactionParams is overwritten without originalTransactionID and source:

    if (isReverseSplitOperation) {
        requestMoneyInformation.transactionParams = {
            amount: splitExpense.amount ?? 0,
            currency: originalTransactionDetails?.currency ?? CONST.CURRENCY.USD,
            // ... other fields but NO originalTransactionID or source!
        };
    }

    This clears the split relationship, causing BUG 1.

    BUG 2 occurs because:

    1. The first split child has been reverted via REVERT_SPLIT_TRANSACTION API call
    2. When the user tries to edit the second split and move it to the same report, the backend rejects it because the original parent transaction's split structure is now inconsistent

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

    Fix getChildTransactions to not require the report to exist when the transaction is part of a deleted report:

    src/libs/TransactionUtils/index.ts:

    function getChildTransactions(transactions: OnyxCollection<Transaction>, reports: OnyxCollection<Report>, originalTransactionID: string | undefined) {
        return Object.values(transactions ?? {}).filter((currentTransaction) => {
            const currentReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${currentTransaction?.reportID}`];
    +       // Include transactions even if their report was deleted, as long as they have the originalTransactionID
    +       // This prevents incorrect isReverseSplitOperation when some split children have deleted reports
    +       const hasValidReportOrDeletedReport = !!currentReport || !currentTransaction?.reportID;
            return (
                currentTransaction?.comment?.originalTransactionID === originalTransactionID &&
    -           !!currentReport &&
    +           hasValidReportOrDeletedReport &&
                currentTransaction?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE
            );
        });
    }

    Alternatively, if we want to be more precise about detecting orphaned split children:

    function getChildTransactions(transactions: OnyxCollection<Transaction>, reports: OnyxCollection<Report>, originalTransactionID: string | undefined) {
        return Object.values(transactions ?? {}).filter((currentTransaction) => {
            const currentReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${currentTransaction?.reportID}`];
    +       const isSplitChild = currentTransaction?.comment?.originalTransactionID === originalTransactionID;
    +       // For split children, we should include them even if their report was deleted
    +       // This is because the split relationship is defined by originalTransactionID, not the report
            return (
    -           currentTransaction?.comment?.originalTransactionID === originalTransactionID &&
    -           !!currentReport &&
    +           isSplitChild &&
    +           (!!currentReport || currentTransaction?.comment?.source === CONST.IOU.TYPE.SPLIT) &&
                currentTransaction?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE
            );
        });
    }

    This ensures that all split children are found, preventing incorrect isReverseSplitOperation determination.

    What alternative solutions did you explore?

    N/A

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jan 6, 2026
  5. changed the title [-]Expense - Split status is removed after editing split, error after editing second split[/-] [+][$250] Expense - Split status is removed after editing split, error after editing second split[/+] on Jan 6, 2026
  6. melvin-bot commented on Jan 6, 2026

    @melvin-bot
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jan 6, 2026
  8. melvin-bot commented on Jan 6, 2026

    @melvin-bot

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

  9. twinkle-react commented on Jan 7, 2026

    @twinkle-react

    🚨 Edited by proposal-police: This proposal was edited at 2026-01-07 05:06:31 UTC.

    Proposal

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

    After editing a split expense, reopening another split sometimes opens the Amount screen instead of Edit Splits, or throws the error: “specified transaction is not one of the split transactions.”
    This happens because the child transaction loses its split identity, causing follow-up edits to fail.


    What is the root cause of that problem?

    Split identity is stored in two places:

    1. SPLIT_TRANSACTION_DRAFT for in-progress edits.
    2. Transaction comment fields: comment.originalTransactionID and comment.source = 'split'.

    updateSplitTransactions relies on the backend response, but the success payload can omit these comment fields. When Onyx merges the success data, it overwrites the child transaction without re-applying the split metadata.
    Result: the app no longer recognizes the transaction as a split child, causing subsequent validation failures and incorrect navigation.


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

    Treat split identity as client-owned:

    1. Maintain split state in SPLIT_TRANSACTION_DRAFT and the persisted transaction comment fields (comment.originalTransactionID and comment.source) on the child transaction.

    2. Add a server-success merge guard:

      • After a successful API response, explicitly re-apply the split metadata to the child transaction if the backend omits it.
      • Ensures originalTransactionID + source: 'split' are always present during the optimistic → success merge cycle.

    Code Snippet :

    successData.push(
        ...(onyxData.successData ?? []),
        ...(updateMoneyRequestParamsOnyxData.successData ?? []),
        {
            // Preserve split metadata even if the server response omits it
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.TRANSACTION}${existingTransactionID}`,
            value: {
                comment: {
                    ...(splitTransaction?.comment ?? {}),
                    originalTransactionID,
                    source: CONST.IOU.TYPE.SPLIT,
                },
            },
        },
    );

    This ensures the child transaction keeps its split identity regardless of the backend response.


    What alternative solutions did you explore? (Optional)

    • Re-deriving split state from report actions was considered but rejected because it is fragile and indirect, and would not reliably maintain split identity across optimistic/success cycles.
  10. ikevin127 commented on Jan 7, 2026

    @ikevin127
    Contributor

    🎉 Thanks everyone for the proposals!

    @MobileMage's proposal review:

    Root Cause Analysis: ⭐⭐⭐⭐⭐ (5/5)

    Correctly identifies the issue in getChildTransactions (TransactionUtils/index.ts : 2419-2432):

    // PROBLEM: !!currentReport requires report to exist
    return (
        currentTransaction?.comment?.originalTransactionID === originalTransactionID &&
        !!currentReport &&  // ← Filters out valid split children when report is deleted
        currentTransaction?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE
    );

    Logic chain explained:

    1. Report deleted → currentReport is undefined.
    2. !!currentReport = false → valid split child excluded.
    3. originalChildTransactions.length returns incorrect count.
    4. isReverseSplitOperation incorrectly becomes true.
    5. REVERT_SPLIT_TRANSACTION API called → clears split metadata.

    Proposed Solution: ⭐⭐⭐⭐⭐ (5/5)

    Strengths:

    • ✅ Fixes at data source level
    • ✅ Uses existing comment.source field (consistent with isExpenseSplit pattern)
    • ✅ Fixes BOTH bugs
    • ✅ Maintains server/client consistency
    • ✅ Single fix location, applies universally

    @twinkle-react's proposal review:

    Root Cause Analysis: ⭐⭐ (2/5)
    Claims the issue is server response omitting split metadata during Onyx merge:

    "The success payload can omit these comment fields. When Onyx merges the success data, it overwrites the child transaction without re-applying the split metadata."

    This is incorrect. The actual problem is that isReverseSplitOperation is incorrectly set to true before any API call is made, causing the wrong API command (REVERT_SPLIT_TRANSACTION) to be sent.

    Proposed Solution: ⭐⭐ (2/5)

    successData.push({
        onyxMethod: Onyx.METHOD.MERGE,
        key: `${ONYXKEYS.COLLECTION.TRANSACTION}${existingTransactionID}`,
        value: {
            comment: {
                originalTransactionID,
                source: CONST.IOU.TYPE.SPLIT,
            },
        },
    });

    Weaknesses:

    • ❌ Treats symptom, not cause
    • ❌ Backend receives wrong API call (REVERT_SPLIT_TRANSACTION)
    • ❌ Creates server/client state mismatch
    • ❌ BUG 2 still unfixed (backend has corrupted split structure)
    • ❌ Introduces non-standard pattern of re-applying metadata post-success

    Comparison Matrix

    Criteria Proposal 1 Proposal 2
    Root Cause Accuracy ✅ Correct ❌ Misdiagnosed
    Fixes BUG 1 ✅ Yes ⚠️ Partially (client-side only)
    Fixes BUG 2 ✅ Yes ❌ No
    Server/Client Consistency ✅ Maintained ❌ Mismatch created
    Code Location ✅ Source (data query) ⚠️ Downstream (API response)
    Follows Existing Patterns ✅ Uses comment.source ⚠️ New merge guard pattern
    Maintainability ✅ Single fix ⚠️ Requires additional guards
    Understanding Demonstrated ✅ Strong ⚠️ Partial
  11. ikevin127 commented on Jan 7, 2026

    @ikevin127
    Contributor

    @MobileMage's proposal looks good to me. RCA is correct and solution fixes both issues (see review breakdown here).

    Rationale:

    • Accurate diagnosis — Correctly identifies that getChildTransactions excludes valid split children when their report is deleted.
    • Correct fix location — Modifies the data query function so all dependent code paths automatically work correctly.
    • Both bugs fixed — BUG 2 is a downstream effect of the same root cause; fixing child transaction discovery prevents the incorrect REVERT_SPLIT_TRANSACTION call.
    • Consistent with codebase — Uses the existing comment.source === CONST.IOU.TYPE.SPLIT pattern already present in isExpenseSplit().
    • No side effects — Maintains server/client state consistency.

    🎀👀🎀 C+ reviewed

  12. 19 remaining items

  13. melvin-bot commented on Jan 21, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.5-7 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2026-01-28. 🎊

    For reference, here are some details about the assignees on this issue:

  14. melvin-bot commented on Jan 21, 2026

    @melvin-bot

    @ikevin127 @JmillsExpensify The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  15. ikevin127 commented on Jan 28, 2026

    @ikevin127
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: N/A - Mistake during implementation

    • [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: N/A

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

    Regression Test Proposal

    1. Go to workspace chat.
    2. Create an expense.
    3. Open expense report.
    4. Click More > Split > Save.
    5. Click More > Delete > Delete the report.
    6. Go to self DM.
    7. Open any split.
    8. Click Report > Create report.
    9. Click Amount.
    10. Edit the amount and save it.
    11. Click Amount field again.
    12. Verify Edit splits page opens (not Amount editor) - BUG 1 FIXED.
    13. Go to self DM.
    14. Open the remaining split.
    15. Click Report > Select the report in Step 9.
    16. Click Amount.
    17. Edit the amount and save it.
    18. Verify no error shows up - BUG 2 FIXED.

    Do we agree 👍 or 👎.

  16. ikevin127 commented on Jan 28, 2026

    @ikevin127
    Contributor

    @JmillsExpensify Ready for payment summary 🙌

  17. ikevin127 commented on Jan 30, 2026

    @ikevin127
    Contributor

    @JmillsExpensify Friendly bump 🙏

  18. ikevin127 commented on Feb 2, 2026

    @ikevin127
    Contributor

    @JmillsExpensify Friendly bump 2

  19. JmillsExpensify commented on Feb 2, 2026

    @JmillsExpensify
    Contributor

    Payment summary:

  20. garrettmknight commented on Feb 2, 2026

    @garrettmknight
    Contributor

    $250 approved for @ikevin127

  21. JmillsExpensify commented on Feb 2, 2026

    @JmillsExpensify
    Contributor

    Regression test created and contributor paid via Upwork.

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