Skip to content

Fix: New expense not visible in grouped-by from search when created offline#92132

Draft
aswin-s wants to merge 2 commits into
Expensify:mainfrom
aswin-s:fix/issue-91453
Draft

Fix: New expense not visible in grouped-by from search when created offline#92132
aswin-s wants to merge 2 commits into
Expensify:mainfrom
aswin-s:fix/issue-91453

Conversation

@aswin-s
Copy link
Copy Markdown
Contributor

@aswin-s aswin-s commented May 30, 2026

Explanation of Change

When the Search view has Group by: From active and the user creates a new expense while offline, the expense was invisible in the grouped list — only appearing after the next online sync.

Root cause: getSearchOnyxUpdate in src/libs/actions/IOU/SearchUpdate.ts already handled the groupBy === FROM case by pushing a snapshot update for the drill-down (per-member) query, but it never wrote a group_<fromAccountID> entry into optimisticSnapshotData for the parent grouped view. getMemberSections in SearchUIUtils.ts renders exclusively from group_-prefixed Onyx keys via isGroupEntry, so with no such key written, the new expense simply had no row to appear in.

Fix:

  1. Inside the groupBy === FROM branch, write a group_<fromAccountID> entry to optimisticSnapshotData shaped as SearchMemberGroup ({ accountID, count, total, currency }).
  2. Subscribe to ONYXKEYS.COLLECTION.SNAPSHOT at module level (same pattern used by other IOU action modules) so the existing group's count, total, and currency are read from live Onyx state and correctly incremented rather than reset to the single new transaction's values.

Fixed Issues

$ #91453
PROPOSAL: #91453 (comment)

Tests

  1. Open New Expensify web app and go to the Search > Expenses view
  2. Apply Group by: From (via Display menu)
  3. Note the current count and total for your user's group row
  4. Disable your network connection (or use DevTools → Network → Offline)
  5. Click + Create → Create expense, enter an amount (e.g. ₹100), select yourself as recipient, confirm
  6. Verify the grouped list immediately shows either:
    • Your existing group row with count + 1 and total + 100, or
    • A new group row if no prior row existed for your account
  7. Re-enable network and verify the row remains consistent after the API sync
  • Verify that no errors appear in the JS console

Offline tests

  1. Follow steps 1–6 above — the entire test is an offline scenario
  2. Verify the group row appears optimistically without any network connection
  3. Verify the group row count/total increment correctly if a group row already existed

QA Steps

  1. Open staging.new.expensify.com
  2. Navigate to Search > Expenses, apply Group by: From
  3. Note your existing group row count and total
  4. Go offline (DevTools Network → Offline)
  5. Create a new expense (Manual, any amount) assigned to yourself
  6. Verify the group row updates immediately (count +1, total += new amount)
  7. Go back online and verify the row is consistent with server data
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)

Screenshots/Videos

Web

aswin-s added 2 commits May 30, 2026 08:51
…ting expense offline

When the search view has groupBy:from active, creating an expense offline
did not write a group_<fromAccountID> entry into optimisticSnapshotData.
getMemberSections renders exclusively from group_-prefixed Onyx keys, so
the new expense was invisible until the next online sync.
The initial fix always computed count:1 and total:transaction.amount
because optimisticSnapshotData is a fresh object per call. Subscribe to
the SNAPSHOT collection at module level so the existing group_ entry can
be read and its count/total incremented correctly. Also preserve the
existing group's currency rather than overwriting it.
@aswin-s aswin-s changed the title [] Fix: New expense not visible in grouped-by-From search when created offline Fix: New expense not visible in grouped-by-From search when created offline May 30, 2026
@aswin-s aswin-s changed the title Fix: New expense not visible in grouped-by-From search when created offline Fix: New expense not visible in grouped-by from search when created offline May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant