Skip to content

[$250] [Exploratory] Vacation Delegate - Error loading after reject 1 split then remove another split #100120

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: v9.4.66-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: https://test-management.browserstack.com/projects/2219752/test-runs/71924520/folder/52723565/41236712/1717128096?sort=%2Bidentifier
Email or phone of affected tester (no customers): leungbratt6+c@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Windows 10/Chrome
App Component: Chat Report View

Action Performed:

Preconditions
4 accounts are needed for this TC:

  • Account A: Workspace owner
  • Account B: Workspace approver
  • Account C: Vacation delegate of user B
  • Account D: Workspace submitter
    As workspace owner, invite all members to the WS, add an approver (Account B) to the workspace
    Steps:
  1. As Account D (submitter), submit an expense to the workspace chat
  2. Log in as Account C (vacation delegate)
  3. Go to any report that needs to be approved by Account B
  4. Click on the Report to view the details
  5. Click on the "More"
  6. Click on the "Split" option
  7. Click on the "Save" button
  8. Click on one of the split expenses and mark it as "Reject" expense
  9. Click on another split - Edit split - Click on amount - Remove split

Expected Result:

No error after remove split

Actual Result:

A Raw JSON {"comment":""} is displayed in the expense report preview on LHN
And error appears after Vacation Delegate rejects one split and removes another

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7248612_1788318667456.vacation.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Julia Ponikarchuk
Bug ID: 7248612

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

Activity

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

    @MelvinBot
    Contributor

    Proposal

    Two separate defects produce what the tester saw. Both live in the split-expense flow in Expensify/App.

    What is the root cause of that problem?

    1. The error after "reject one split, remove the other" — the split flow doesn't know a split can be rejected.

    Rejecting a split moves that child transaction onto a brand-new OPEN expense report, but it keeps comment.source === 'split' and comment.originalTransactionID, so getChildTransactions still returns it as a live sibling. It is rebuilt into the split draft with statusNum: 0 at SplitExpenseItems.ts:337.

    That 0 flips the reverse-split flag at SplitTransactionUpdate.ts:300-301:

    const hasEditableSplitExpensesLeft = splitExpenses.some((expense) => (expense.statusNum ?? 0) < CONST.REPORT.STATUS_NUM.SUBMITTED);
    const isReverseSplitOperation = splitExpenses.length === 1 && allChildTransactions.length > 0 && hasEditableSplitExpensesLeft;

    So removing the second split stops being "delete one split" and becomes a full un-split: the app fires REVERT_SPLIT_TRANSACTION targeting the rejected transaction, which now lives on a different report. It also optimistically deletes the surviving child and navigates away from the report it believes is about to be empty. The write fails, iou.error.genericEditFailureMessage is applied, and the user is left on the error/not-found screen.

    Without the reject, both children are statusNum: 1 (SUBMITTED), the flag is false, and the save takes the normal UPDATE_SPLIT_TRANSACTION path — which is why the flow only breaks when a split was rejected first.

    2. The raw {"comment":""} in the LHN — comment is sent as a serialized object.

    The split payload builds comment as a nested object at SplitTransactionUpdate.ts:352-354, and every object-valued field is stringified into the API params at SplitTransactionUpdate.ts:2023-2027. With no description that sends literally splits[0][comment] = {"comment":""}. The sibling REVERT_SPLIT_TRANSACTION branch flattens it to a plain string; SPLIT_TRANSACTION / UPDATE_SPLIT_TRANSACTION do not — the two commands disagree on the shape of the same field. That string comes back as the expense description and is rendered verbatim by getDescription → getReportPreviewMessage, giving $X.XX for {"comment":""}.

    This fires at the Split → Save step (step 7), not at remove — it is independent of the reject.

    The vacation delegate is not causal. isDelegateAccessRestricted only applies to the submitter role, and the Split / Edit split / Remove split paths have no delegate guard at all. Connecting as a delegate makes the session act as the delegator, so account B acting directly should reproduce this identically.

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

    1. Exclude rejected children from the split set. Filter transactions that have been rejected off the original expense report out of getChildTransactions (or out of the draft rebuild in initSplitExpenseItemData), so a rejected split can no longer contribute statusNum: 0 and no longer becomes the target of a revert. This is the fix that stops the error.
    2. Harden the reverse-split guard. hasEditableSplitExpensesLeft should mean "this split is still editable on the report we're editing", so it should also require the remaining split to still be on expenseReport.reportID — not merely have a low statusNum.
    3. Send comment in one consistent shape. Flatten comment to the description string in the SPLIT_TRANSACTION / UPDATE_SPLIT_TRANSACTION branch the same way the revert branch already does, so the raw JSON can never be stored as a description.

    What alternative solutions did you explore? (Optional)

    Escaping or sanitizing the description at render time would hide the {"comment":""} text but leaves the wrong value stored on the transaction, so it was rejected.

    Supporting evidence and open questions

    Repro-specific note: the reverse-split root cause requires exactly 2 splits, so removing one leaves 1. With 3+ splits the save instead sends UPDATE_SPLIT_TRANSACTION with the rejected, off-report split still in the payload and a silently redistributed amount — a different but equally wrong outcome from the same missing filter.

    Amount redistribution side effect: removeSplitExpenseField unlocks the remaining splits and redistributes the full original amount onto the survivor — here, the rejected expense that is no longer on the report.

    Not verified: the backend handlers for REVERT_SPLIT_TRANSACTION / UPDATE_SPLIT_TRANSACTION are not in this repo, so the exact server response and the hop that stores {"comment":""} as the description are inferred from the client payload, not observed. The client-side changes above are still correct regardless.

    Not reproduced locally: this repro needs four accounts with an approver and a configured vacation delegate, which is out of reach of the automated test harness.

    Related: [$250] Expense - Report in LHN shows "tracked x for {"comment"'''}" after deleting split track expense (Expensify/App#64239) is the same {"comment":""} defect class in a different split flow. It was closed without a fix, so change 3 above would close both.


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/100120) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.


    view run

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Sep 24, 2026
  4. melvin-bot commented on Sep 24, 2026

    @melvin-bot

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

  5. melvin-bot commented on Sep 24, 2026

    @melvin-bot

    Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

  6. ashusatyarthi-wq commented on Sep 26, 2026

    @ashusatyarthi-wq

    Proposal

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

    In a split expense flow where a Vacation Delegate (or user):

    1. Rejects one split expense.
    2. Then edits and removes another split expense.

    Two defects occur:

    1. An unexpected error appears when submitting the change.
    2. A raw JSON string {"comment":""} is displayed in the expense report preview in the Left Hand Navigation (LHN) and chat.

    What is the root cause of that problem?

    There are two distinct root causes producing these symptoms:

    1. Unexpected error on removing split: isReverseSplitOperation misidentifies rejected splits

    When a split expense is rejected, the app moves that transaction onto a new report, but the transaction still retains comment.source === 'split' and comment.originalTransactionID.

    Consequently, in SplitTransactionUpdate.ts:287:

    const allChildTransactions = getChildTransactions(allTransactionsList, originalTransactionID);

    getChildTransactions returns the rejected transaction as a live child because it searches solely by originalTransactionID without verifying whether the child belongs to the current report (expenseReport.reportID).

    Then at SplitTransactionUpdate.ts:300-301:

    const hasEditableSplitExpensesLeft = splitExpenses.some((expense) => (expense.statusNum ?? 0) < CONST.REPORT.STATUS_NUM.SUBMITTED);
    const isReverseSplitOperation = splitExpenses.length === 1 && allChildTransactions.length > 0 && hasEditableSplitExpensesLeft;

    Because allChildTransactions.length > 0 includes the off-report rejected transaction, reducing the active split count to 1 incorrectly trips isReverseSplitOperation = true. Instead of performing an UPDATE_SPLIT_TRANSACTION, the app triggers REVERT_SPLIT_TRANSACTION targeting the rejected transaction on another report. The API command fails on the server and applies iou.error.genericEditFailureMessage.

    2. Raw JSON {"comment":""} in LHN: comment object stringified instead of flattened

    In SplitTransactionUpdate.ts:352-354, the splits parameter structures comment as a nested object:

    comment: {
        comment: currentDescription,
    },

    When preparing parameters for SPLIT_TRANSACTION / UPDATE_SPLIT_TRANSACTION at SplitTransactionUpdate.ts:2024-2027:

    const splitApiParams = {} as Record<string, string | number | boolean>;
    for (const [i, split] of splits.entries()) {
        for (const [key, value] of Object.entries(split)) {
            splitApiParams[`splits[${i}][${key}]`] = value !== null && typeof value === 'object' ? JSON.stringify(value) : value;
        }
    }

    Any value of type object is passed through JSON.stringify(value). Because split.comment is {comment: currentDescription}, JSON.stringify(split.comment) serializes to {"comment":""} (or {"comment":"..."}).

    This stringified JSON is sent as splits[${i}][comment] = "{\"comment\":\"\"}". Unlike REVERT_SPLIT_TRANSACTION (which explicitly flattens comment: splits.at(0)?.comment?.comment), the update split loop sends the raw JSON object string, which the backend saves verbatim and getReportPreviewMessage displays in the LHN preview.


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

    Fix 1: Filter allChildTransactions to the current report

    In src/libs/actions/IOU/SplitTransactionUpdate.ts:
    Filter allChildTransactions so that transactions that have been rejected/moved off the current expenseReport.reportID are excluded from the reverse-split calculation:

    -    const allChildTransactions = getChildTransactions(allTransactionsList, originalTransactionID);
    +    const allChildTransactions = getChildTransactions(allTransactionsList, originalTransactionID).filter(
    +        (child) => child.reportID === expenseReport?.reportID,
    +    );

    And ensure hasEditableSplitExpensesLeft confirms the remaining split belongs to expenseReport?.reportID.

    Fix 2: Flatten comment string in splitApiParams

    In src/libs/actions/IOU/SplitTransactionUpdate.ts:2024-2028:
    Explicitly extract the inner comment string rather than JSON-stringifying the {comment: ...} container:

             for (const [i, split] of splits.entries()) {
                 for (const [key, value] of Object.entries(split)) {
    -                splitApiParams[`splits[${i}][${key}]`] = value !== null && typeof value === 'object' ? JSON.stringify(value) : value;
    +                if (key === 'comment') {
    +                    splitApiParams[`splits[${i}][comment]`] = split.comment?.comment ?? '';
    +                } else {
    +                    splitApiParams[`splits[${i}][${key}]`] = value !== null && typeof value === 'object' ? JSON.stringify(value) : value;
    +                }
                 }
             }

    What specific scenarios should be covered in tests?

    1. Rejected split removal test:

      • Create a report with 2 split transactions.
      • Reject split Some initial fixes and code style updates #1 (moves to a separate report).
      • Edit split Fix spaces #2 and remove a split.
      • Assert isReverseSplitOperation is false and UPDATE_SPLIT_TRANSACTION is invoked without throwing generic edit errors.
    2. Comment serialization test:

      • Trigger a split expense with empty description and with non-empty description.
      • Inspect API parameters for SPLIT_TRANSACTION / UPDATE_SPLIT_TRANSACTION.
      • Assert splits[0][comment] is sent as a plain string ("" or "my description"), never as '{"comment":""}'.
      • Assert LHN preview displays formatted currency without JSON artifact.

    What alternative solutions did you explore? (Optional)

    1. Sanitizing {"comment":""} in getReportPreviewMessage / getDescription:
      • Rejected because treating the symptom at render time leaves corrupted JSON stored in the transaction's description field in the database.
    2. Modifying getChildTransactions globally:
      • Rejected because other callers (like audit log or transaction history) may genuinely want to inspect all historical children across reports. Scoping the filter to SplitTransactionUpdate.ts is more surgical and minimizes regression risk.
  7. melvin-bot commented on Sep 29, 2026

    @melvin-bot

    @shubham1206agra Eep! 4 days overdue now. Issues have feelings too...

  8. 136 remaining items

  9. mallenexpensify commented on Nov 16, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @apeyada paid $250 via Upwork
    Contributor+: @mkhutornyi due $250 via NewDot

    @apeyada can you please accept the job below? Please reply here and tag me once you have.
    https://www.upwork.com/jobs/~022108552439518103803

  10. apeyada commented on Nov 19, 2026

    @apeyada
    Contributor

    @mallenexpensify I accepted. Thanks

  11. trjExpensify commented on Nov 20, 2026

    @trjExpensify
    Contributor

    approved $250 for @mkhutornyi

  12. changed the title [-][Due for payment 2026-11-14] [$250] [Exploratory] Vacation Delegate - Error loading after reject 1 split then remove another split[/-] [+][$250] [Exploratory] Vacation Delegate - Error loading after reject 1 split then remove another split[/+] on Nov 20, 2026
  13. removed their assignment
    on Nov 20, 2026
  14. mallenexpensify commented on Nov 20, 2026

    @mallenexpensify
    Contributor

    @apeyada paid, summary updated above. Thx.

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