@@ -468,19 +468,31 @@ type GetYourSpendSnapshotSplitUpdatesParams = {
468468 // Signed change to the report's reimbursable total, in the transaction/report currency
469469 // (new split total minus the pre-split total). Negative when the expense is split to a lower amount.
470470 reimbursableDiff : number ;
471+ // Signed change to the number of reimbursable transactions in the report caused by the split
472+ // (e.g. splitting one expense into two reimbursable children is +1). `count` drives the Home row's
473+ // visibility, so it must move in lockstep with the membership change even when `reimbursableDiff` is 0
474+ // (an equal-amount split leaves the total unchanged but still adds transactions).
475+ reimbursableCountDiff : number ;
471476 currentUserAccountID : number ;
472477} ;
473478
474479/**
475- * Optimistically patches the "Awaiting approval" snapshot total when a SUBMITTED expense is split and the resulting
476- * reimbursable total changes (e.g. split to a lower amount). The report stays in the awaiting-approval section, so this
477- * is a same-section amount delta rather than a state move. Home reads totals from `snapshot.search.total`, which is only
478- * refreshed online. Mirrors the amount-edit path: same-currency only (the currency guard in
479- * `buildSnapshotTotalUpdatesForHash` skips a mismatch, since FX conversion isn't available offline).
480+ * Optimistically patches the "Awaiting approval" snapshot when a SUBMITTED expense is split. A split keeps the report
481+ * in the awaiting-approval section but changes both its reimbursable total (e.g. split to a lower amount) and the number
482+ * of reimbursable transactions it contains (one expense becomes several). Home reads `snapshot.search.total`/`count`,
483+ * which are only refreshed online, and `count` drives the row's visibility — so both must be patched, even when the
484+ * total is unchanged (an equal-amount split still changes `count`). Mirrors the amount-edit path: same-currency only
485+ * (the currency guard in `buildSnapshotTotalUpdatesForHash` skips a mismatch, since FX conversion isn't available offline).
480486 */
481- function getYourSpendSnapshotSplitUpdates ( { iouReport, originalTransaction, reimbursableDiff, currentUserAccountID} : GetYourSpendSnapshotSplitUpdatesParams ) : YourSpendSnapshotOnyxData {
487+ function getYourSpendSnapshotSplitUpdates ( {
488+ iouReport,
489+ originalTransaction,
490+ reimbursableDiff,
491+ reimbursableCountDiff,
492+ currentUserAccountID,
493+ } : GetYourSpendSnapshotSplitUpdatesParams ) : YourSpendSnapshotOnyxData {
482494 const result : YourSpendSnapshotOnyxData = { optimisticData : [ ] , successData : [ ] , failureData : [ ] } ;
483- if ( ! iouReport || ! originalTransaction || reimbursableDiff === 0 ) {
495+ if ( ! iouReport || ! originalTransaction || ( reimbursableDiff === 0 && reimbursableCountDiff === 0 ) ) {
484496 return result ;
485497 }
486498
@@ -491,7 +503,7 @@ function getYourSpendSnapshotSplitUpdates({iouReport, originalTransaction, reimb
491503
492504 const currency = getCurrency ( originalTransaction ) ;
493505 const approvalQueryJSON = buildSearchQueryJSON ( buildAwaitingApprovalQuery ( currentUserAccountID , paidGroupPolicyIDs ) ) ;
494- mergeYourSpendSnapshotOnyxData ( result , buildSnapshotTotalUpdatesForHash ( approvalQueryJSON ?. hash , reimbursableDiff , currency ) ) ;
506+ mergeYourSpendSnapshotOnyxData ( result , buildSnapshotTotalUpdatesForHash ( approvalQueryJSON ?. hash , reimbursableDiff , currency , reimbursableCountDiff ) ) ;
495507 return result ;
496508}
497509
0 commit comments