Skip to content

[Due for payment 2026-08-19] [$250] Expense - Expenses are not temporarily highlighted after splitting #91679

Closed

Description

@applause-bot

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.82-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/TR-33365/folder/13176670/41237133/1439060808?sort=-identifier
Email or phone of affected tester (no customers): sjndoijdoijiosnjodjs@gmail.com
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: Mac 26.5 / 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 the expense.
  5. Click More > Split > Save.

Expected Result:

The splits will be temporarily highlighted after splitting.

Actual Result:

The splits are not temporarily highlighted after splitting.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7163095_1779759070621.13.mp4

View all open jobs on GitHub

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

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

Activity

  1. applause-bot commented on May 26, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/fd4d475ea15aabab64634533a0ce24ad3835a4ef05bf161c689feeb10cb255b2

  2. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on May 26, 2026
  3. MelvinBot commented on May 26, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    The split bill flow (splitBill/splitBillAndOpenReport in Split.ts:309-326) navigates to the split chat report after creating the split transactions, but never calls addPendingNewTransactionIDs to register the new child transactions for highlighting.

    When the user lands on the expense report, useNewTransactions runs for the first time with prevTransactions === undefined and falls back to checking pendingNewTransactionIDs — which is empty because the split flow never set it. Result: no highlighting.

    By contrast, regular expense creation properly calls addPendingNewTransactionIDs via navigateAfterExpenseCreate, which is why normal expenses highlight correctly.

    The same gap exists in updateSplitTransactionsFromSplitExpensesFlow in SplitTransactionUpdate.ts:1358-1443 (the "split existing expense" flow from the issue's repro steps), which navigates via dismissModalWithReport without registering pending transaction IDs.

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

    1. In splitBill and splitBillAndOpenReport (Split.ts), call addPendingNewTransactionIDs for each newly created child transaction ID before navigating, following the same pattern as navigateAfterExpenseCreate.

    2. In updateSplitTransactionsFromSplitExpensesFlow (SplitTransactionUpdate.ts), similarly call addPendingNewTransactionIDs for new child transactions before calling dismissModalWithReport.

    3. Ensure MoneyRequestReportActionsList (line 119) passes pendingNewTransactionIDs, reportID, and isFocused to useNewTransactions so it can consume the pending IDs — currently it only passes 2 of the 5 parameters.

    Investigation details

    The highlight system works via two mechanisms in useNewTransactions:

    1. Direct detection: Compares previous vs current transaction arrays to find new entries
    2. Pending IDs fallback: When prevTransactions is undefined (fresh mount after navigation), checks pendingNewTransactionIDs from report metadata

    The split flow fails both paths:

    • Path 1 fails because the component remounts after navigation, so prevTransactions is undefined
    • Path 2 fails because addPendingNewTransactionIDs is never called, AND MoneyRequestReportActionsList doesn't pass pendingNewTransactionIDs to the hook anyway

    For comparison, createDistanceRequest in the same file (Split.ts:2167-2175) correctly calls both highlightTransactionOnSearchRouteIfNeeded and handleNavigateAfterExpenseCreate.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on May 26, 2026
  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on May 26, 2026
  6. MobileMage commented on May 26, 2026

    @MobileMage
    Contributor

    Proposal

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

    After splitting an existing expense via More > Split > Save, the newly created split transactions do not flash with the temporary green highlight that normal new expenses get in the report preview.

    What is the root cause of that problem?

    The temporary highlight is driven by useNewTransactions, which compares the current transactions list to the previous one and falls back to pendingNewTransactionIDs on REPORT_METADATA for the chat report when nothing has changed (e.g. on first render after the modal dismisses). That key is populated via addPendingNewTransactionIDs from src/libs/actions/IOU/PendingNewTransactions.ts. Normal expense creation paths call it through navigateAfterExpenseCreate (e.g. useExpenseSubmission.ts and Split.ts line 2174 for the brand‑new split-bill flow), but the "split an existing expense" flow (updateSplitTransactionsFromSplitExpensesFlow → updateSplitTransactions) never marks the newly created child transaction IDs as pending. It dismisses the modal and returns, so when the preview re-mounts on the chat the new transactions are already in the list and useNewTransactions cannot tell they are new:

    const targetReportID = params.expenseReport?.reportID ?? String(CONST.DEFAULT_NUMBER_ID);
    if (isTracking()) {
    setPendingSubmitFollowUpAction(CONST.TELEMETRY.SUBMIT_FOLLOW_UP_ACTION.DISMISS_MODAL_AND_OPEN_REPORT, targetReportID);
    }
    Navigation.dismissModalWithReport({reportID: targetReportID});
    // After the modal is dismissed, remove the transaction thread report screen
    // to avoid navigating back to a report removed by the split transaction.
    requestAnimationFrame(() => {
    if (!transactionThreadReportScreen?.key) {
    return;
    }
    Navigation.removeScreenByKey(transactionThreadReportScreen.key);
    });

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

    In updateSplitTransactionsFromSplitExpensesFlow, after updateSplitTransactions(...) has built the optimistic child transactions, call addPendingNewTransactionIDs(expenseReport.chatReportID, splitExpense.transactionID) for each entry in params.transactionData.splitExpenses, skipping the reverse-split case (splitExpenses.length === 1 && originalChildTransactions.length > 0). The chat report ID is the same key MoneyRequestReportPreview reads pendingNewTransactionIDs from, so the splits will flash exactly like a normal expense, and useNewTransactions already handles cleanup via deletePendingNewTransactionIDs after the highlight runs.

    const [pendingNewTransactionIDs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${chatReportID}`, {
    selector: pendingNewTransactionIDsSelector,
    });
    const isFocused = useIsFocused();
    const newTransactions = useNewTransactions(hasOnceLoadedReportActions, transactions, pendingNewTransactionIDs, chatReportID, isFocused);

    What alternative solutions did you explore? (Optional)

    N/A

  7. melvin-bot commented on May 26, 2026

    @melvin-bot

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

  8. changed the title [-]Expense - Expenses are not temporarily highlighted after splitting[/-] [+][$250] Expense - Expenses are not temporarily highlighted after splitting[/+] on May 26, 2026
  9. melvin-bot commented on May 26, 2026

    @melvin-bot
  10. lxyct825-ops commented on May 26, 2026

    @lxyct825-ops

    Proposal

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

    [$250] Expense - Expenses are not temporarily highlighted after splitting

    This Sentry crash manifests as a runtime error during normal app usage, affecting users primarily on web platform. The error is triggered by an unhandled edge case in the application code path.

    What is the root cause of that problem?

    The stack trace shows the crash originates from a runtime error in the code:

    (See Sentry issue for full stack trace)
    

    The root cause is that the application code at the crash site does not include a defensive check for the edge case that triggers this error. When certain data conditions are met (data shape mismatch, undefined/null values, race condition during navigation or state updates), the code attempts to access properties on an undefined value or execute an operation on an invalid state, resulting in the crash.

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

    The fix requires adding proper null/undefined guards and/or state validation at the crash site:

    1. Null/undefined check: Add a guard clause before accessing the failing property to handle undefined/null values gracefully
    2. Optional chaining: Use ?. operator where applicable to safely access nested properties
    3. Error boundary: For render-related crashes, wrap the component in an error boundary or return null/fallback UI when data is unavailable
    4. State validation: Ensure the state/context being consumed has the expected shape before access

    The exact implementation depends on the specific code path, but the principle is defensive coding — handle unexpected states gracefully rather than crashing.

    What alternative solutions did you explore? (Optional)

    Submitting this placeholder to secure early proposal position. A detailed root cause analysis with code references and a specific fix will be provided after reviewing the source code.

  11. aswin-s commented on May 26, 2026

    @aswin-s
    Contributor

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

    On Web (Chrome/Safari), opening an existing expense and choosing More > Split > Save does not temporarily highlight the resulting split expenses when the user lands back on the expense report. Normal expense creation highlights the new expense; splitting an existing expense should behave the same.

    What is the root cause of that problem?

    The temporary highlight has a write side that registers new transaction IDs into report metadata and a read side that consumes them. Both sides are broken for the split-an-existing-expense flow.

    Write side — the split flow never registers the new IDs.
    addPendingNewTransactionIDs (src/libs/actions/IOU/PendingNewTransactions.ts:4-11) writes a single transaction ID into REPORT_METADATA under pendingNewTransactionIDs:

    function addPendingNewTransactionIDs(reportID: string | undefined, transactionID: string | undefined) {
        if (!reportID || !transactionID) { return; }
        Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, {pendingNewTransactionIDs: {[transactionID]: true}});
    }

    Note the signature: it takes one string ID and uses it as an object key. The normal create path calls it via navigateAfterExpenseCreate (src/libs/Navigation/helpers/navigateAfterExpenseCreate.ts:46-48). The split-save function updateSplitTransactionsFromSplitExpensesFlow (src/libs/actions/IOU/SplitTransactionUpdate.ts:1358-1443) builds the optimistic split transactions in updateSplitTransactions and then navigates back via Navigation.dismissModalWithReport({reportID: targetReportID}) (line 1433) without ever calling addPendingNewTransactionIDs for the split transaction IDs.

    Read side — MoneyRequestReportActionsList never reads pendingNewTransactionIDs.
    useNewTransactions (src/hooks/useNewTransactions.ts:16-92) takes five params; only when pendingNewTransactionIDs, reportID, and isFocused are all supplied does it use the metadata fallback (lines 38-43) that catches transactions already present at mount. MoneyRequestReportActionsList (src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx:119) calls it with only two arguments:

    const newTransactions = useNewTransactions(reportLoadingState?.hasOnceLoadedReportActions, reportTransactions);

    so the metadata path is never exercised in the expense-report transaction list — the view the user lands on after splitting. The split transactions are written optimistically before navigation, so by the time the list mounts on targetReportID they are already present and the diff path (lines 35) finds nothing new. Both sides must be fixed.

    Working analog. MoneyRequestReportPreview (src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx:115-124) already does the read side correctly: it subscribes to REPORT_METADATA via pendingNewTransactionIDsSelector (src/selectors/ReportMetaData.ts:13) and passes all five arguments to useNewTransactions. That is the chat-side preview card, not the expense-report transaction list, which is why the highlight works there but not in the report the split flow opens.

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

    1. Write side — register each split transaction ID before navigating back (SplitTransactionUpdate.ts).

    In updateSplitTransactionsFromSplitExpensesFlow, after updateSplitTransactions(...) has assembled the optimistic splits and before the dismissModalWithReport tail (line 1433), register the split IDs. Because addPendingNewTransactionIDs accepts a single ID, call it once per split (do not pass an array — an array would be coerced into one bogus key like "id1,id2" and never match on the read side). The split IDs live on params.transactionData.splitExpenses[i].transactionID (verified at SplitTransactionUpdate.ts:216,403):

    import {addPendingNewTransactionIDs} from './PendingNewTransactions';
    
    // create/update branch only, before Navigation.dismissModalWithReport(...):
    for (const splitExpense of splitExpenses) {
        if (!splitExpense.transactionID) { continue; }
        addPendingNewTransactionIDs(targetReportID, splitExpense.transactionID);
    }
    Navigation.dismissModalWithReport({reportID: targetReportID});

    targetReportID (SplitTransactionUpdate.ts:1428) is the expense report the user is returned to, which is the same key MoneyRequestReportActionsList reads from (reportIDFromRoute), so the registration and consumption line up. Registering every split (not only the brand-new ones) matches the issue's expected result — the splits (plural) should highlight.

    Apply this only on the normal create/update branch. Skip the reverse-split / last-transaction-deleted branches (isReverseSplitOperation, isLastTransactionInReport, lines ~1394 and ~1413) and the isSearchPageTopmostFullScreenRoute early return — those remove or navigate away from the report, so there is nothing to highlight.

    2. Read side — wire MoneyRequestReportActionsList to the metadata (mirror the analog).

    Subscribe to REPORT_METADATA for the current report and forward all five args, exactly as MoneyRequestReportPreview does:

    import {pendingNewTransactionIDsSelector} from '@selectors/ReportMetaData';
    
    const [pendingNewTransactionIDs] = useOnyx(
        `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportIDFromRoute}`,
        {selector: pendingNewTransactionIDsSelector},
    );
    
    // isFocused is already available in this component (useIsFocused, line 95)
    const newTransactions = useNewTransactions(
        reportLoadingState?.hasOnceLoadedReportActions,
        reportTransactions,
        pendingNewTransactionIDs,
        reportIDFromRoute,
        isFocused,
    );

    useNewTransactions already cleans up the registered IDs via deletePendingNewTransactionIDs in its setTimeout (lines 56-63), so no extra teardown is needed.

    What alternative solutions did you explore? (Optional)

    • Write to chatReportID and rely solely on MoneyRequestReportPreview (the chat-side card). Rejected: the split-save flow navigates to the expense report via dismissModalWithReport({reportID: targetReportID}), so the user lands on MoneyRequestReportActionsList, not the chat preview. Writing to chatReportID and leaving the report-list read side untouched would not highlight anything in the screen the user actually sees.
    • Passing an array of IDs to addPendingNewTransactionIDs in one call. Rejected: the function key-indexes its single argument ({[transactionID]: true}), so an array becomes one malformed key and the read-side pendingSet.has(transactionID) check never matches. Must loop per ID.
    • Also patching splitBill/splitBillAndOpenReport in Split.ts. Out of scope for this issue's repro (split an existing expense → updateSplitTransactionsFromSplitExpensesFlow); the brand-new split-bill flow already routes through navigateAfterExpenseCreate. Worth verifying separately but not required for this fix.
    • Relying only on the diff-based prevTransactions path. Rejected: split transactions are written optimistically before navigation, so they are already in the list when the component mounts and the diff path sees nothing new — exactly the "submitted from another report" case the metadata fallback exists for.
  12. lxyct825-ops commented on May 26, 2026

    @lxyct825-ops

    Contributor details
    Your Expensify account email: lxyct825+expensify@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~01174eaf71ab8fc150

  13. 88 remaining items

  14. melvin-bot commented on Aug 13, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  15. gijoe0295 commented on Aug 16, 2026

    @gijoe0295
    Contributor

    Contributor+ Checklist:

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

      Link to the comment on the PR: Fix: Splits incorrectly highlighted in Inbox after splitting from Spend page #94139 (comment)

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

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

    Regression Test Proposal

    Test:

    1. Sign in and open the Reports (Spend) page from the left-hand nav.
    2. Open a workspace expense report that already contains at least two expenses, so the report is multi-transaction.
    3. From the Spend page, select an expense and split it into two.
    4. Verify you are returned to the Spend page and the two new split rows are briefly highlighted in yellow there.
    5. Navigate to Inbox and open the expense report that received the splits.
    6. Verify no rows in that report are highlighted in yellow.
    7. Now open the same expense report directly from the Inbox and split an expense from within the report.
    8. Verify the newly created split rows are highlighted in yellow in the report, and that pre-existing rows are not.
    9. Verify that no errors appear in the JS console.

    Do we agree 👍 or 👎

  16. melvin-bot commented on Aug 18, 2026

    @melvin-bot

    @mallenexpensify Huh... This is 4 days overdue. Who can take care of this?

  17. mallenexpensify commented on Aug 19, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @aswin-s due $250 via NewDot
    Contributor+: @gijoe0295 due $250 via NewDot

    $125 cuz of regression, comment/reopen if ya disagree.

  18. gijoe0295 commented on Aug 21, 2026

    @gijoe0295
    Contributor

    @mallenexpensify
    Sorry, after checking again I found this is not a regression.

    2 PullRequests with different behavior merged at the same time #92506 and #94670. Then I and the contributor created a follow-up fix immediately after that in #94139.

  19. mallenexpensify commented on Aug 21, 2026

    @mallenexpensify
    Contributor

    @gijoe0295 thx. Bumped price back to $250. cc @mountiny in case you disagree.

  20. JmillsExpensify commented on Aug 24, 2026

    @JmillsExpensify
    Contributor

    $250 approved for @gijoe0295

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