Skip to content

[Due for payment 2026-10-02] [$250] [INP] Improve SplitExpense-SaveButton interaction #97802

Closed

Description

@rlinoz

Problem

SplitExpense-SaveButton has the worst p75 INP of any labelled interaction in the app, and it is trending the wrong way. The "good" threshold is 200 ms; anything over 500 ms is "poor".

Window p75 INP Interactions Severity count × (p75−200)²
14d 800.0 ms 230 53M
7d 816.0 ms 139 53M

Where it is

  • Label constant: CONST.SENTRY_LABEL.SPLIT_EXPENSE.SAVE_BUTTON (src/CONST/index.ts)
  • Applied in src/pages/iou/SplitExpensePage.tsx, on the Save button
  • Handler: onSaveSplitExpense in the same file

Hypothesis: whole-collection Onyx subscriptions

SplitExpensePage.tsx subscribes to eight Onyx collections, seven of them unfiltered:

Subscription Selector?
useOnyx(ONYXKEYS.COLLECTION.REPORT) no
useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS) no
useOnyx(ONYXKEYS.COLLECTION.POLICY) no
useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS) no
useOnyx(ONYXKEYS.COLLECTION.SNAPSHOT) no
useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS) no
useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST) no
useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS, {selector: ...}) yes

plus useAllTransactions(). Every one of these except POLICY_TAGS is read whole and then handed straight into updateSplitTransactionsFromSplitExpensesFlow as allTransactionsList, allReportsList, allReportActionsList, allReportNameValuePairsList, allSnapshots, allPolicyTags.

This is the fix that has already been proven to work

Remove redundant Onyx subscriptions when editing IOURequest (PR #90338) attacked exactly this class of problem and is the one fix in this programme that demonstrably moved production p75. Every RequestConfirmationList-* field it touched now sits at 136–184 ms, comfortably under the threshold.

Read that PR before proposing anything here.

Secondary cost on the press

onSaveSplitExpense runs up to three deepEqual comparisons over the full split set and its child transactions before it does anything useful, plus computeSplitSaveErrorMessage. These are synchronous and sit on the critical path to paint.

A high-traffic account is mandatory here

On a fresh account these collections are tiny and this bug is invisible — you will measure a fast button and conclude there is nothing to fix.

Reproduce and measure with a high-traffic account against the staging or production API, per PERFORMANCE.md §4.

Reference

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

Activity

  1. added
    Weekly
    Improvement
    on Aug 4, 2026
  2. self-assigned this
    on Aug 4, 2026
  3. added
    External
    on Aug 4, 2026
  4. melvin-bot commented on Aug 4, 2026

    @melvin-bot

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

  5. added
    Daily
    and removed
    Weekly
    on Aug 4, 2026
  6. melvin-bot commented on Aug 4, 2026

    @melvin-bot
  7. added
    Help Wanted
    on Aug 4, 2026
  8. changed the title [-][INP] Improve `SplitExpense-SaveButton` interaction[/-] [+][$250] [INP] Improve `SplitExpense-SaveButton` interaction[/+] on Aug 4, 2026
  9. j3ffffff commented on Aug 4, 2026

    @j3ffffff
  10. lorretheboy commented on Aug 4, 2026

    @lorretheboy
    Contributor

    Proposal

    What is the root cause of that problem?

    SplitExpensePage holds eight unfiltered Onyx subscriptions, but three of them (REPORT_NAME_VALUE_PAIRS, SNAPSHOT, PERSONAL_DETAILS_LIST) are never used in render at all — they exist purely to be forwarded as arguments to the save action — and two more (REPORT_ACTIONS, TRANSACTION_VIOLATIONS) are only read for a single key each:

    const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
    const [allReportNameValuePairs] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS);
    const [allSnapshots] = useOnyx(ONYXKEYS.COLLECTION.SNAPSHOT);

    const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS);
    const [quickAction] = useOnyx(ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE);
    const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST);

    The causal chain on the press: onSaveSplitExpense synchronously calls updateSplitTransactionsFromSplitExpensesFlow, which builds optimistic money-request data for every split and commits Onyx writes to the transaction, report, report-actions and snapshot collections → those are exactly the collections this page subscribes to whole, so every commit rebuilds the huge collection snapshots and re-renders the page's expensive unmemoized body (per-split isSplitAction, getTransactionDetails, the options mapping) — several times, all before the frame can paint. On a high-traffic account those collections are large, which is why p75 sits at ~800 ms while a fresh account looks fine.

    The collections are only handed straight through here:

    updateSplitTransactionsFromSplitExpensesFlow({
    allTransactionsList: allTransactions,
    allReportsList: allReports,
    allReportActionsList: allReportActions,
    allReportNameValuePairsList: allReportNameValuePairs,
    allSnapshots,
    allPolicyTags,

    This is the same class of problem as PR #90338 (redundant Onyx traffic on the save path); that PR didn't touch this page, so this isn't a regression from it — the pattern was simply never applied here.

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

    Fix at the action level, since SplitExpensePage is the only caller of updateSplitTransactionsFromSplitExpensesFlow. The IOU actions module already keeps Onyx.connect-backed caches with getters for every one of these collections — and SplitTransactionUpdate.ts already imports one of them:

    function getAllPersonalDetails(): OnyxTypes.PersonalDetailsList {
    return allPersonalDetails;
    }
    function getAllTransactions(): NonNullable<OnyxCollection<OnyxTypes.Transaction>> {
    return allTransactions;
    }
    /**
    * @deprecated Use `useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS)` in components and pass the data down as a parameter instead.
    */
    // TODO: https://github.com/Expensify/App/issues/66512
    function getAllTransactionViolations(): NonNullable<OnyxCollection<OnyxTypes.TransactionViolations>> {
    return allTransactionViolations;
    }
    function getAllReports(): OnyxCollection<OnyxTypes.Report> {
    return allReports;
    }
    function getAllReportActionsFromIOU(): OnyxCollection<OnyxTypes.ReportActions> {
    return allReportActions;
    }
    function getAllReportNameValuePairs(): OnyxCollection<OnyxTypes.ReportNameValuePairs> {
    return allReportNameValuePairs;
    }
    function getAllTransactionDrafts(): NonNullable<OnyxCollection<OnyxTypes.Transaction>> {
    return allTransactionDrafts;
    }
    function getCurrentUserPersonalDetails(): OnyxEntry<OnyxTypes.PersonalDetails> {
    return deprecatedCurrentUserPersonalDetails;
    }
    function getRecentAttendees(): OnyxEntry<Attendee[]> {
    return recentAttendees;
    }
    function getAllSnapshots(): OnyxCollection<OnyxTypes.SearchResults> {
    return allSnapshots;
    }

    import {getAllReports} from './index';

    So:

    1. In updateSplitTransactionsFromSplitExpensesFlow, drop the allTransactionsList / allReportsList / allReportActionsList / allReportNameValuePairsList / allSnapshots / personalDetails / transactionViolations params and read them at call time via getAllTransactions, getAllReports, getAllReportActionsFromIOU, getAllReportNameValuePairs, getAllSnapshots, getAllPersonalDetails, getAllTransactionViolations. These are press-time snapshot reads, so freshness is identical to what the subscriptions provided.
    2. In SplitExpensePage, delete the subscriptions that only fed the action (REPORT_NAME_VALUE_PAIRS, SNAPSHOT, PERSONAL_DETAILS_LIST), and narrow the two collections the render reads a single key from: subscribe to ${REPORT_ACTIONS}${iouReportIDForActions} instead of the whole collection (its only render use is the lookup in iouActions), and to ${TRANSACTION_VIOLATIONS}${transactionID} (only used for currentTransactionViolations).
    3. Minor cleanup on the same path: deepEqual(splitFieldDataFromChildTransactions, splitExpenses) is computed in two places in onSaveSplitExpense; compute it once.

    REPORT, POLICY and the transactions collection are genuinely used throughout the render, so they stay (narrowing them with selectors can be a follow-up). After the change, the optimistic writes from the save no longer re-render this page through five now-removed/narrowed subscriptions, and the page stops re-rendering on unrelated updates to those collections while open. Verify with a high-traffic account per PERFORMANCE.md, comparing React Profiler traces of the Save press before/after.

    What alternative solutions did you explore? (Optional)

    Keeping the action's signature and instead reading the collections inside onSaveSplitExpense at press time from the same getters. It gives the identical INP win, but leaves a misleading API that invites the next caller to reintroduce whole-collection subscriptions, so changing the action (single call site) is cleaner.

  11. 112 remaining items

  12. mallenexpensify commented on Oct 5, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @Abdukhamid000 paid $125 via Upwork
    Contributor+: @ikevin127 due $125 via NewDot

    @Abdukhamid000 can you please apply to the job below? Please reply here and tag me once you have.

    Deploy Blocker #99805 was identified to be related to this PR.

    I'm assuming pay is half for the deploy blocker and revert, comment if you disagree.

  13. ikevin127 commented on Oct 5, 2026

    @ikevin127
    Contributor

    Thanks for the summary, I'll be requesting $125 as well even though it says $250 (probably typo) 🙌

  14. mallenexpensify commented on Oct 5, 2026

    @mallenexpensify
    Contributor

    probably typo)

    yup, apologies. updated to $125

  15. Abdukhamid000 commented on Oct 6, 2026

    @Abdukhamid000
    Contributor

    @mallenexpensify in link saying This job is no longer available.

  16. mallenexpensify commented on Oct 6, 2026

    @mallenexpensify
    Contributor

    @Abdukhamid000 can you try again, it's showing as open to me
    https://www.upwork.com/jobs/~022107115148034462931
    If you're still having troubles, please share your upwork profile link

  17. Abdukhamid000 commented on Oct 7, 2026

    @Abdukhamid000
    Contributor
  18. added
    Daily
    and removed
    Daily
    on Oct 7, 2026
  19. mallenexpensify commented on Oct 7, 2026

    @mallenexpensify
    Contributor

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

  20. Abdukhamid000 commented on Oct 8, 2026

    @Abdukhamid000
    Contributor

    Thanks @mallenexpensify I've accepted the offer on Upwork and submitted the job. 🙏

  21. mallenexpensify commented on Oct 8, 2026

    @mallenexpensify
    Contributor

    @Abdukhamid000 paid, summary updated above. Thx.

  22. quinthar commented on Oct 13, 2026

    @quinthar
    Contributor

    Approved $125 to @ikevin127

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentDailyExternalImprovementPerformance

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions