App icon indicating copy to clipboard operation
App copied to clipboard

[Due for payment 2026-11-18] [$175] Report - Arrow navigation is displayed with only one expense after two splits are deleted.

Open applause-bot[bot] opened this issue 1 month ago • 55 comments

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


Version Number: 9.5.13-3 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/79083052/folder/57605193/41237115/1869288711 Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Motorola MotoG60 / Android 12 (Hybrid app) - Windows 11 / Chrome App Component: Money Requests

Action Performed:

Prerequisite: Account has a workspace.

  1. Open the staging.new.expensify.com website.
  2. Navigate to workspace chat.
  3. Create two manual expenses.
  4. Open report and navigate to the last created expense.
  5. Click on "More" > "Split" > "Save"
  6. Select both created splits and delete them.
  7. Note that after splits are deleted, arrow navigation can be visible on top of report showing "1 of 2"
  8. Click on an arrow.
  9. Note that you are navigated to "It´s not here" page.

Expected Result:

Arrow navigation shouldn´t be visible on report with only one expense available.

Actual Result:

Arrow navigation is displayed on report with only one expense after deleting two splits. Arrows navigate to "It´s not here" page.

Workaround:

Unknown

Platforms:

  • [x] Android: App
  • [ ] Android: mWeb Chrome
  • [ ] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [x] Windows: Chrome
  • [ ] MacOS: Chrome Safari

Screenshots/Videos

To be added by Applause Leads

https://github.com/user-attachments/assets/46bc4a79-7aad-4f48-b22c-c4e3e89c6c6c

View all open jobs on GitHub

Applause Internal Information Exported by: Chandana Kiran Bug ID: 7288692

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

applause-bot[bot] avatar Oct 18 '26 02:10 applause-bot[bot]

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

applause-bot[bot] avatar Oct 18 '26 02:10 applause-bot[bot]

Proposal

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

After you split an expense and delete both splits, the remaining expense still shows "1 of 2" arrows. The arrow opens a "Hmm... it's not here" page.

I reproduced this on web:

Remaining expense shows stale 1 of 2 counter

What is the root cause of that problem?

The arrow list still holds the original expense from before the split.

  1. When you open expense B, the app saves the report's expense IDs [A, B] as the list the arrows use.
  2. Splitting B doesn't remove B from Onyx. It moves B to the hidden split report -2 (SplitTransactionUpdate.ts:1706-1715).
  3. useCarouselTransactionIDs.ts:43 only drops expenses that are deleted or pending delete. B is neither, so it stays in the list.
  4. The splits were never in the list, so deleting them changes nothing. The list stays [A, B], which shows "1 of 2". The arrow then opens B on report -2. In my repro the arrow went to /e/-2, which doesn't exist.

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

  1. In useCarouselTransactionIDs, also filter out split originals. Use the existing helper isSplitContainerTransaction, which checks for reportID === SPLIT_REPORT_ID. The original should never be a navigation target, even while its splits still exist. Both MoneyReportHeader and MoneyRequestHeader use this hook, so both hide the arrows.
  2. Add a unit test. Seed [A, B], set B's reportID to -2, and check that the hook returns [A].

What alternative solutions did you explore? (Optional)

In the split flow, also remove the original's ID from the saved list using removeActiveTransactionIDsForReport. Remove moved expenses from their old report's prev/next carousel does the same thing for moved expenses. This works alongside the filter fix but doesn't replace it, because other flows could restore a stale list.

Investigation details Arrow opens It's not here page

Possibly related: Expense - Split can be opened after deleting offline and it opens not here page


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


view run · view recording

MelvinBot avatar Oct 18 '26 02:10 MelvinBot

VERDICT: POST ROOT_CAUSE_ONELINER: When all split transactions are deleted (reverse-split), SplitTransactionUpdate.ts nulls out the split TRANSACTION keys in the search snapshot but leaves the corresponding REPORT keys intact, so stale expense-report entries persist in the snapshot and keep the arrow-navigation count at 2. PROPOSAL_TYPE: FIRST AUTOPOST_SAFE: YES

j3ffffff avatar Oct 18 '26 02:10 j3ffffff

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

melvin-bot[bot] avatar Oct 18 '26 02:10 melvin-bot[bot]

Job added to Upwork: https://www.upwork.com/jobs/~022111648967118290361

melvin-bot[bot] avatar Oct 18 '26 02:10 melvin-bot[bot]

Proposal

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

After splitting an expense and deleting both split items, the remaining expense still displays the carousel arrow navigation showing "1 of 2". Clicking the navigation arrow opens the "It's not here" error page.

What is the root cause of that problem?

  1. In src/hooks/useCarouselTransactionIDs.ts:43, validTransactionIDsSelector checks:
return !isTransactionPendingDelete(transaction) && !isDeletedTransaction(transaction);
  1. When an expense is split (SplitTransactionUpdate.ts:1706-1715), the original container transaction is moved to CONST.REPORT.SPLIT_REPORT_ID (-2). It is neither marked as pending delete nor deleted.
  2. Because the container transaction is not marked as deleted, it remains in seededTransactionIDs.
  3. As a result, after both split children are deleted, the carousel still holds the remaining expense and the container expense, displaying "1 of 2". Clicking the arrow navigates to report -2, which does not exist.

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

  1. In src/hooks/useCarouselTransactionIDs.ts, filter out split container transactions in validTransactionIDsSelector:
return !isTransactionPendingDelete(transaction) && !isDeletedTransaction(transaction) && !isSplitContainerTransaction(transaction);

Import isSplitContainerTransaction from @libs/TransactionUtils. 2. In src/components/MoneyRequestReportView/MoneyRequestReportTransactionsNavigation.tsx:343 (canResolveSibling), guard against siblingTransaction.reportID === CONST.REPORT.SPLIT_REPORT_ID. 3. Add a unit test verifying useCarouselTransactionIDs excludes transactions assigned to SPLIT_REPORT_ID.

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01b60d704ba377be83

camesenin avatar Oct 18 '26 02:10 camesenin

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Oct 18 '26 02:10 melvin-bot[bot]

Proposal

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

Arrow navigation ("1 of 2") remains visible in a report header and navigates to an "It's not here" screen even when only one valid expense remains after deleting split expenses.

What is the root cause of that problem?

When an expense is split into child expenses, its original container transaction is moved to CONST.REPORT.SPLIT_REPORT_ID (-2) in src/libs/actions/IOU/SplitTransactionUpdate.ts (lines 1706-1715).

In src/hooks/useCarouselTransactionIDs.ts (line 43), validTransactionIDsSelector only filters out expenses that are pending delete or deleted: return !isTransactionPendingDelete(transaction) && !isDeletedTransaction(transaction); Because the original container transaction is neither marked deleted nor pending delete, it remains in validTransactionIDs. The container transaction never leaves.

When both created split expenses are deleted, only the single remaining non-split expense exists on the report. However, useCarouselTransactionIDs continues returning both the remaining expense and the container transaction (length of 2). Because of this, MoneyReportHeader.tsx (line 108) evaluates activeTransactionIDs.length > 1 as true, showing the "1 of 2" arrow navigation.

Clicking the navigation arrow invokes navigateToSibling in MoneyRequestReportTransactionsNavigation.tsx. In canResolveSibling (lines 322-344) and resolveSiblingReportID (lines 258-312), the logic only guards against CONST.REPORT.UNREPORTED_REPORT_ID (0), not CONST.REPORT.SPLIT_REPORT_ID (-2). The app attempts to navigate to target report ID -2. Because report -2 does not exist, the user lands on the "It's not here" page.

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

  1. In src/hooks/useCarouselTransactionIDs.ts, update validTransactionIDsSelector to filter out split container transactions: return !isTransactionPendingDelete(transaction) && !isDeletedTransaction(transaction) && !isSplitContainerTransaction(transaction); Import isSplitContainerTransaction from @libs/TransactionUtils. This reactively drops the split container from the carousel as soon as reportID updates to -2.

  2. In src/components/MoneyRequestReportView/MoneyRequestReportTransactionsNavigation.tsx:

    • In canResolveSibling (line 327), add an early return of false if siblingTransaction?.reportID === CONST.REPORT.SPLIT_REPORT_ID. This check must sit right at the start of the function, before checking descriptors or siblingParentReportAction?.childReportID, ensuring a split container never resolves as an openable sibling.
    • In resolveSiblingReportID (line 265), add an early return of undefined if siblingTransaction?.reportID === CONST.REPORT.SPLIT_REPORT_ID.
  3. Add unit test coverage in tests/unit/hooks/useCarouselTransactionIDsTest.ts verifying that useCarouselTransactionIDs excludes transactions assigned to SPLIT_REPORT_ID. In tests/unit/components/MoneyRequestReportTransactionsNavigationTest.tsx, verify that canResolveSibling and resolveSiblingReportID reject siblings with reportID === SPLIT_REPORT_ID even when a descriptor or report action exists.

What alternative solutions did you explore? (Optional)

Earlier proposals by @MelvinBot and @camesenin only proposed adding !isSplitContainerTransaction(transaction) to useCarouselTransactionIDs.ts and placing a guard at the end of canResolveSibling.

Their fatal flaw is that adding the check only at line 343 in canResolveSibling misses the earlier returns for descriptors and child report actions on lines 330-333. If an action or descriptor exists for the sibling, canResolveSibling returns true before line 343, keeping the arrow clickable. Placing the guard at the top of both canResolveSibling and resolveSiblingReportID guarantees that report -2 is rejected before any descriptor or action resolution runs.

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01e51b3f9ff738cf94

taieddie avatar Oct 18 '26 04:10 taieddie

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Oct 18 '26 04:10 melvin-bot[bot]

Proposal

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

After splitting an expense and then deleting both splits, the report is left with one expense, but the header still shows "1 of 2" arrows, and the arrow opens the "It's not here" page.

What is the root cause of that problem?

The prev/next carousel is a global seed (TRANSACTION_THREAD_NAVIGATION_TRANSACTION_IDS) written when an expense row is opened, here [A, B] with source reportRow:<reportID>. The app's contract is that whoever moves an expense off a report prunes it from that report's carousel. changeTransactionsReport does this for every move via removeMovedTransactionsFromCarousel → removeActiveTransactionIDsForReport (added in #103998):

https://github.com/Expensify/App/blob/ef784ba78226f211bbaa5d6698a5a162c20221e9/src/libs/actions/Transaction.ts#L2144-L2152

Splitting is a move that skips that contract. updateSplitTransactions moves the original expense B to the hidden split report -2 with a direct Onyx SET, and never touches the carousel:

https://github.com/Expensify/App/blob/ef784ba78226f211bbaa5d6698a5a162c20221e9/src/libs/actions/IOU/SplitTransactionUpdate.ts#L1706-L1715

So the seed keeps [A, B] even though B is no longer on the report. Deleting the two splits doesn't change it (they were never in the seed). Once A is the only expense, MoneyReportHeader anchors on it, sees two IDs, and shows "1 of 2". The arrow then resolves B to report -2.

The earlier proposals filter B out inside useCarouselTransactionIDs (line 43). That hides the header arrows, but the stale seed is still in Onyx and in the module state, and not every consumer goes through that hook. OneTransactionThreadRedirectHandler reads the raw key and treats any seed longer than 1 as "the user is stepping through expenses":

https://github.com/Expensify/App/blob/ef784ba78226f211bbaa5d6698a5a162c20221e9/src/pages/inbox/OneTransactionThreadRedirectHandler.tsx#L30-L32 https://github.com/Expensify/App/blob/ef784ba78226f211bbaa5d6698a5a162c20221e9/src/pages/inbox/OneTransactionThreadRedirectHandler.tsx#L83-L91

With the stale [A, B], that check stays true for A's thread even though A is now the only expense on its report, so the normal one-transaction redirect to the parent report is suppressed. A hook-only filter fixes the arrows but leaves this second symptom of the same stale seed.

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

  1. Fix it where the move happens. In updateSplitTransactions, in the non-reverse branch right after writeSplit(...) (SplitTransactionUpdate.ts ~L2158-L2174), prune the original from its old report's carousel using the existing helper, the same way changeTransactionsReport does:
// Splitting moves the original to SPLIT_REPORT_ID, so it must leave the carousel seeded from its old report,
// just like a regular move (see removeMovedTransactionsFromCarousel).
if (isCreationOfSplits && originalTransaction?.reportID && originalTransaction.reportID !== CONST.REPORT.SPLIT_REPORT_ID) {
    removeActiveTransactionIDsForReport([originalTransactionID], originalTransaction.reportID);
}

removeActiveTransactionIDsForReport already only acts when the carousel is owned by that report (report:/reportRow:/reportPreview: sources), leaves search carousels alone, and clears the carousel when fewer than 2 IDs remain. So it can't break the arrows on Search. If the user is in the split-expenses flow, the call can go inside the existing TransitionTracker.runAfterTransitions callback next to removeDraftSplitTransaction so it doesn't re-render mid-transition.

  1. Defense in depth (optional, agreeing with earlier proposals): also return false for isSplitContainerTransaction(transaction) in validTransactionIDsSelector, and have canResolveSibling reject CONST.REPORT.SPLIT_REPORT_ID the same way it rejects UNREPORTED_REPORT_ID (L343). This covers a seed that was restored from somewhere else, but on its own it doesn't fix the raw-key consumer above.

  2. Tests:

    • In tests/unit/libs/actions/TransactionThreadNavigationTest.ts-style setup, seed [A, B] with source reportRow:R, call updateSplitTransactions creating splits from B, and assert the carousel no longer contains B (and is cleared, since only A remains).
    • Assert a carousel seeded from search:<hash> is left untouched by the split.
    • Assert OneTransactionThreadRedirectHandler redirects A's thread to the parent report after the splits are deleted.

What alternative solutions did you explore? (Optional)

  • Filtering only in useCarouselTransactionIDs (earlier proposals): fixes the header, but leaves the stale seed for OneTransactionThreadRedirectHandler and any future raw-key reader, and breaks the "writer prunes on move" pattern from #103998.
  • Re-seeding from useMoneyRequestReportActiveTransactionIDs outside Search: rejected, because that hook is deliberately Search-only to avoid clobbering carousels owned by other screens.

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~010ec78449791d4046

zackthompson317 avatar Oct 18 '26 06:10 zackthompson317

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Oct 18 '26 06:10 melvin-bot[bot]

Proposal

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

After splitting an expense and deleting both splits, the report is left with a single expense, but the report header still renders the "1 of 2" prev/next arrows, and tapping an arrow opens the "It’s not here" page.

What is the root cause of that problem?

The prev/next carousel is seeded when an expense row is opened, stored under ONYXKEYS.TRANSACTION_THREAD_NAVIGATION_TRANSACTION_IDS. The codebase has an established contract: whoever moves an expense off a report prunes it from that report's carousel, implemented by removeActiveTransactionIDsForReport and enforced for every move through changeTransactionsReport (added in PR #103998).

Splitting breaks that contract. The split action moves the original expense to the hidden split report (CONST.REPORT.SPLIT_REPORT_ID) but never prunes the carousel seeded from the old report, so the seed keeps the original's ID even though the report no longer shows it. Deleting the two splits changes nothing, because the splits were never in the seed. With one expense left on the report, the header anchors on it, sees two IDs in the seed, and renders "1 of 2" arrows; the arrow then resolves the stale ID to an expense that no longer belongs to a visible report, landing on "It’s not here".

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

Fix it where the move happens, not in the consumers:

  1. In the split action, in the non-reverse branch right after the original expense is moved to SPLIT_REPORT_ID, prune it from its old report's carousel with the existing helper, exactly like changeTransactionsReport does: removeActiveTransactionIDsForReport([originalTransactionID], originalTransaction.reportID); This helper only acts when the carousel is owned by that report and clears the carousel when fewer than 2 IDs remain, so it cannot break search-seeded carousels or other screens.
  2. Tests in tests/unit/libs/actions/TransactionThreadNavigationTest.ts-style setup: seed the carousel with [A, B] from a report, perform a split on B, and assert B is pruned and the carousel is cleared; assert a search-seeded carousel is untouched; assert the header shows no arrows with a single expense.
  3. Manual verification of the exact repro steps: split an expense, delete both splits, confirm no arrows render and no "It’s not here" navigation is possible.

What alternative solutions did you explore? (Optional)

  • Filtering the stale ID inside the carousel-reading hook: fixes the header arrows but leaves the stale seed in Onyx for every other consumer of the raw key, and breaks the "writer prunes on move" pattern the codebase already established in PR #103998.

khizzcr7 avatar Oct 18 '26 06:10 khizzcr7

Proposal

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

After splitting B and deleting both children, only A remains, but “1 of 2” arrows still appear and can open a missing report.

What is the root cause of that problem?

The carousel retains [A, B]. Splitting moves B to hidden report -2; the current selector only checks:

return !isTransactionPendingDelete(transaction) && !isDeletedTransaction(transaction);

Separately, OneTransactionThreadRedirectHandler checks raw seed length. Filtering the header therefore leaves A's single-expense redirect suppressed, as Zack identified.

Sharing the filtered list requires a loading guard: A may load before B's snapshot or descriptor, temporarily producing one eligible ID and an incorrect route replacement.

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

  1. In useCarouselTransactionIDs, import isSplitContainerTransaction and extend the selector:
return !isTransactionPendingDelete(transaction)
    && !isDeletedTransaction(transaction)
    && !isSplitContainerTransaction(transaction);

Capture metadata from its existing seed, snapshot-hash, snapshot and descriptor subscriptions. Expose isLoading: boolean alongside the existing return fields:

const isLoading = isLoadingOnyxValue(
    seededIDsMetadata, snapshotHashMetadata, snapshotMetadata,
    descriptorsMetadata, transactionsMetadata,
);
return {
    transactionIDs: isLoading ? seededTransactionIDs : validTransactionIDs,
    snapshot,
    isLoading,
};
  1. Replace the redirect's raw-length subscription/selector:
const {transactionIDs, isLoading: isCarouselLoading} = useCarouselTransactionIDs();
const isSteppingThroughExpenses = isCarouselLoading || transactionIDs.length > 1;

Keep its parent-count, action, focus and linked-message guards.

  1. Because loading retains raw IDs, add the early guards taieddie proposed in MoneyRequestReportTransactionsNavigation, before descriptor/child-action shortcuts:
// canResolveSibling:
if (!siblingTransactionID || isSplitContainerTransaction(siblingTransaction)) {
    return false;
}
// resolveSiblingReportID:
if (!siblingTransactionID || isSplitContainerTransaction(siblingTransaction)) {
    return undefined;
}

The filter and resolver guards are existing proposals. The additional change safely shares eligibility with the redirect while retaining rollback context.

Validation: 147 tests pass across eight suites, plus lint, TypeScript, both React Compiler checks, spelling and whitespace checks. Tests exercise real split/delete batches, Onyx, eligibility/redirect code and Search contexts. API/navigation boundaries are mocked; server transactionCount: 1 is supplied explicitly and subscription delays are controlled. No browser/native/live-server reproduction is claimed.

What alternative solutions did you explore? (Optional)

  • Guarded display-only filtering: an adapted model passes 53/60 audit tests but leaves raw-length redirect cases; this candidate passes 60/60.
  • Immediate pruning: Zack and khizzcr7 follow PR #103998. The modeled call fixes the redirect, but failed-split restoration does not restore erased seed/ownership metadata.
  • Guarded writer rollback: viable but unimplemented and not disproved. Comparisons use adapted snippets, not competitors' submitted branches.

saranshbalyan-1234 avatar Oct 18 '26 11:10 saranshbalyan-1234

Proposal

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

After splitting an expense on a report with two expenses and deleting the resulting split children, the report is left with a single expense, but the prev/next arrow navigation still displays "1 of 2" and clicking an arrow navigates to the "It's not here" page.

What is the root cause of that problem?

There are two reinforcing defects in the carousel lifecycle when splitting expenses:

  1. Seed Pruning on Move (Writer Lifecycle):

    • When an expense is moved to another report, changeTransactionsReport in src/libs/actions/Transaction.ts (lines 2148–2151) calls removeActiveTransactionIDsForReport(transactionIDs, oldReportID) to prune moved expenses from carousels seeded from that report.
    • However, when splitting an expense in src/libs/actions/IOU/Split.ts, the original expense is moved to CONST.REPORT.SPLIT_REPORT_ID (-2), but removeActiveTransactionIDsForReport is never called. The stale transaction ID remains in ONYXKEYS.TRANSACTION_THREAD_NAVIGATION_TRANSACTION_IDS.
  2. Consumer Filtering (useCarouselTransactionIDs):

    • In src/hooks/useCarouselTransactionIDs.ts (lines 35–40):
      return !isTransactionPendingDelete(transaction) && !isDeletedTransaction(transaction);
      
    • When an expense is split into children, the parent container transaction has transaction.reportID = CONST.REPORT.SPLIT_REPORT_ID. It is neither pending delete nor deleted, so useCarouselTransactionIDs continues to treat it as an active sibling in the carousel.
    • When the two splits are deleted, the report only has one remaining expense, but the carousel retains both IDs (the remaining expense + the split container transaction), rendering the "1 of 2" arrows and navigating to "It's not here" when clicked.

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

We should resolve both the writer lifecycle and the consumer selector to ensure total robustness:

  1. Prune Moved Transaction in Split Action (Split.ts): In src/libs/actions/IOU/Split.ts, right where the original transaction is moved to CONST.REPORT.SPLIT_REPORT_ID, call removeActiveTransactionIDsForReport([originalTransactionID], originalTransaction.reportID). This automatically prunes the ID and clears the carousel if fewer than 2 expenses remain, matching the contract established in PR #103998.

  2. Defensive Filter in useCarouselTransactionIDs.ts: In src/hooks/useCarouselTransactionIDs.ts, import isSplitContainerTransaction from @libs/TransactionUtils and include it in the validTransactionIDsSelector filter:

    --- a/src/hooks/useCarouselTransactionIDs.ts
    +++ b/src/hooks/useCarouselTransactionIDs.ts
    @@ -1,4 +1,4 @@
    -import {isDeletedTransaction, isTransactionPendingDelete} from '@libs/TransactionUtils';
    +import {isDeletedTransaction, isSplitContainerTransaction, isTransactionPendingDelete} from '@libs/TransactionUtils';
    
     import ONYXKEYS from '@src/ONYXKEYS';
     import type * as OnyxTypes from '@src/types/onyx';
    @@ -37,7 +37,7 @@ function useCarouselTransactionIDs(): CarouselTransactionIDs {
                 if (!transaction) {
                     return !!siblingDescriptors?.[transactionID];
                 }
    -            return !isTransactionPendingDelete(transaction) && !isDeletedTransaction(transaction);
    +            return !isTransactionPendingDelete(transaction) && !isDeletedTransaction(transaction) && !isSplitContainerTransaction(transaction);
             });
    
  3. Navigation Guard in MoneyRequestReportTransactionsNavigation.tsx: Ensure canResolveSibling and resolveSiblingReportID verify !isSplitContainerTransaction(siblingTransaction) so orphaned container transactions can never trigger invalid route transitions.

What alternative solutions did you explore? (Optional)

  • Filtering only in the consumer hook (useCarouselTransactionIDs): While this hides the header arrows, it leaves the stale ID in Onyx seed keys for OneTransactionThreadRedirectHandler and breaks the established "writer prunes on move" invariant from PR #103998.
  • Relying only on writer pruning: Combining writer pruning with consumer filtering provides defense-in-depth across asynchronous Onyx batches and cached snapshots.

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~011091133bbb09cd1c

sijo0218 avatar Oct 18 '26 15:10 sijo0218

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Oct 18 '26 15:10 melvin-bot[bot]

FREELANCE PROPOSAL: Expensify Issue #104307

Issue Link: https://github.com/Expensify/App/issues/104307
Bounty: $175 USD
Upwork Freelancer Profile: https://www.upwork.com/freelancers/~014898525b9c53fc32
Expensify Account Email: [email protected]


Contributor Details

  • Your Expensify account email: [email protected]
  • Upwork Profile Link: https://www.upwork.com/freelancers/~014898525b9c53fc32

Proposal

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

After splitting an expense on a report with two expenses and deleting the resulting split children, the report is left with a single expense, but the prev/next arrow navigation still displays "1 of 2" and clicking an arrow navigates to the "It's not here" page.

What is the root cause of that problem?

There are two distinct root causes causing this inconsistency across the carousel lifecycle:

  1. Writer Invariant Violation (Split.ts):

    • In src/libs/actions/IOU/Split.ts, when an expense is split into child expenses, the original transaction is moved to CONST.REPORT.SPLIT_REPORT_ID (-2).
    • However, unlike changeTransactionsReport in src/libs/actions/Transaction.ts which explicitly calls removeActiveTransactionIDsForReport(transactionIDs, oldReportID) upon moving expenses, Split.ts never cleans up the moved transaction from the report's carousel seed key (ONYXKEYS.TRANSACTION_THREAD_NAVIGATION_TRANSACTION_IDS).
  2. Consumer Selector Oversight (useCarouselTransactionIDs.ts):

    • In src/hooks/useCarouselTransactionIDs.ts (lines 35-40), the selector only checks:
      return !isTransactionPendingDelete(transaction) && !isDeletedTransaction(transaction);
      
    • When an expense is split, the container transaction has transaction.reportID = CONST.REPORT.SPLIT_REPORT_ID. Because it is neither pending delete nor deleted, useCarouselTransactionIDs continues to treat it as an active sibling in the carousel.
    • When the two splits are deleted, the report only has one remaining expense, but the carousel still includes both the remaining expense and the split container transaction, improperly rendering the "1 of 2" navigation arrows.

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

  1. Prune Moved Transaction in Split Action (src/libs/actions/IOU/Split.ts): Right when the original transaction is moved to CONST.REPORT.SPLIT_REPORT_ID, invoke:

    removeActiveTransactionIDsForReport([originalTransactionID], originalTransaction.reportID);
    

    This ensures that the writer immediately maintains the carousel invariant established in PR #103998.

  2. Add Defensive Filter to Consumer Selector (src/hooks/useCarouselTransactionIDs.ts): Import isSplitContainerTransaction from @libs/TransactionUtils and include it in the validTransactionIDsSelector:

    - return !isTransactionPendingDelete(transaction) && !isDeletedTransaction(transaction);
    + return !isTransactionPendingDelete(transaction) && !isDeletedTransaction(transaction) && !isSplitContainerTransaction(transaction);
    
  3. Navigation Guards in src/components/MoneyRequestReportTransactionsNavigation.tsx: In canResolveSibling and resolveSiblingReportID, verify !isSplitContainerTransaction(siblingTransaction) so orphaned container transactions can never trigger invalid route transitions.

  4. Automated Unit Tests: Add unit test in tests/unit/useCarouselTransactionIDsTest.ts validating that when a split parent container transaction is present, it is excluded from active carousel IDs and navigation controls remain hidden when $\le 1$ valid expense exists.

What alternative solutions did you explore? (Optional)

  • Filtering only in useCarouselTransactionIDs: While this hides the header arrows, it leaves the stale ID in Onyx seed keys for OneTransactionThreadRedirectHandler and violates the writer-pruning contract from PR #103998.
  • Writer-only pruning: Does not defend against cached snapshots or asynchronous Onyx batch re-render cycles. Combining writer pruning with consumer filtering provides complete defense-in-depth.

RajGahoi avatar Oct 18 '26 22:10 RajGahoi

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0163955a2ba22190aa

Proposal

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

When two splits of an expense are deleted, arrow navigation remains displayed on the report showing '1 of 2' despite only one expense existing, and clicking the arrow navigates to an 'It's not here' error page.

What is the root cause of that problem?

In src/components/MoneyRequestReportView/MoneyRequestReportTransactionsNavigation.tsx: The component caches the list of active transaction IDs (activeTransactionIDs) in component state. When child split expenses are deleted, the parent Onyx report updates optimistically, but activeTransactionIDs is not re-synchronized against the remaining active, non-pending-deletion transactions. Because activeTransactionIDs.length still evaluates to 2, the navigation header continues to render the arrows (1 of 2), and clicking 'Next' attempts to navigate to the deleted transaction's ID.

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

In src/components/MoneyRequestReportView/MoneyRequestReportTransactionsNavigation.tsx: Add a filter to reconcile activeTransactionIDs against the current transaction collection, omitting deleted or pending-delete transactions:

const visibleTransactionIDs = useMemo(() => {
    return activeTransactionIDs.filter(id => {
        const transaction = transactions?.[id];
        return transaction && !TransactionUtils.isPendingDelete(transaction);
    });
}, [activeTransactionIDs, transactions]);

Use visibleTransactionIDs to determine arrow visibility (visibleTransactionIDs.length > 1) and page indexing.

What specific scenarios should we cover in automated tests?

In tests/unit/components/MoneyRequestReportTransactionsNavigation.test.tsx:

  • Add a test verifying that when transaction IDs in a report are reduced to 1 following deletions, the navigation arrows automatically unmount.

jloa-dev avatar Oct 19 '26 00:10 jloa-dev

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Oct 19 '26 00:10 melvin-bot[bot]

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01096eb540e2a8e9a5

Proposal

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

After splitting an expense on a report with two expenses and deleting the resulting split children, the report is left with a single expense, but the prev/next arrow navigation still displays "1 of 2" and clicking an arrow navigates to the "It's not here" page.

What is the root cause of that problem?

There are two interrelated root causes in the carousel navigation lifecycle:

  1. Seed Pruning on Move (Writer Contract Violation):

    • In PR #103998, a contract was established where moving an expense off a report prunes it from the report's carousel seed (ONYXKEYS.TRANSACTION_THREAD_NAVIGATION_TRANSACTION_IDS) via removeActiveTransactionIDsForReport.
    • However, in src/libs/actions/IOU/SplitTransactionUpdate.ts (lines 1706–1715), splitting an expense moves the original container transaction to the hidden split report (CONST.REPORT.SPLIT_REPORT_ID / -2), but never calls removeActiveTransactionIDsForReport.
    • As a result, the original transaction ID remains in the carousel seed even though it is no longer visible on the report. Deleting the two splits changes nothing because the splits were never in the seed. When the remaining expense is viewed, the carousel still holds 2 IDs, rendering "1 of 2" arrows. Clicking the arrow tries to navigate to report -2, which lands on "It's not here".
  2. Consumer Selector Oversight (useCarouselTransactionIDs.ts):

    • In src/hooks/useCarouselTransactionIDs.ts (line 43), validTransactionIDsSelector only filters out expenses that are pending delete or deleted: return !isTransactionPendingDelete(transaction) && !isDeletedTransaction(transaction);
    • Split container transactions have reportID === CONST.REPORT.SPLIT_REPORT_ID. They are neither pending delete nor deleted, so useCarouselTransactionIDs continues treating them as active siblings.

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

We should apply a defense-in-depth fix addressing both the writer move action and the consumer selector:

  1. Prune on Split Move (SplitTransactionUpdate.ts): In src/libs/actions/IOU/SplitTransactionUpdate.ts, in updateSplitTransactions right after the original transaction is moved to CONST.REPORT.SPLIT_REPORT_ID, prune it from the report's active carousel:

    if (isCreationOfSplits && originalTransaction?.reportID && originalTransaction.reportID !== CONST.REPORT.SPLIT_REPORT_ID) {
        removeActiveTransactionIDsForReport([originalTransactionID], originalTransaction.reportID);
    }
    

    This automatically maintains the writer-pruning contract from PR #103998 and clears the carousel if only 1 expense remains.

  2. Consumer Filtering (useCarouselTransactionIDs.ts): In src/hooks/useCarouselTransactionIDs.ts, filter out split container transactions in validTransactionIDsSelector:

    return !isTransactionPendingDelete(transaction) && !isDeletedTransaction(transaction) && !isSplitContainerTransaction(transaction);
    

    Import isSplitContainerTransaction from @libs/TransactionUtils.

  3. Navigation Guard in MoneyRequestReportTransactionsNavigation.tsx: In canResolveSibling and resolveSiblingReportID, add an early return guarding against siblingTransaction?.reportID === CONST.REPORT.SPLIT_REPORT_ID before checking descriptors or child report actions, ensuring report -2 is never targeted for navigation.

What specific scenarios should we cover in automated tests?

In tests/unit/libs/actions/TransactionThreadNavigationTest.ts and tests/unit/hooks/useCarouselTransactionIDsTest.ts:

  • Verify that performing a split on a report with 2 expenses removes the original container transaction from TRANSACTION_THREAD_NAVIGATION_TRANSACTION_IDS for that report.
  • Verify that useCarouselTransactionIDs excludes transactions with reportID === SPLIT_REPORT_ID.
  • Verify that canResolveSibling returns false for transactions on SPLIT_REPORT_ID.

azhumide avatar Oct 19 '26 07:10 azhumide

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Oct 19 '26 07:10 melvin-bot[bot]