Skip to content

Confirm new expenses with a “View” toast instead of scrolling to and highlighting the row - #96496

Open
mhawryluk wants to merge 25 commits into
Expensify:mainfrom
software-mansion-labs:declarative-expense-added-growl
Open

Confirm new expenses with a “View” toast instead of scrolling to and highlighting the row#96496
mhawryluk wants to merge 25 commits into
Expensify:mainfrom
software-mansion-labs:declarative-expense-added-growl

Conversation

@mhawryluk

@mhawryluk mhawryluk commented Jul 20, 2026

Copy link
Copy Markdown
Member

Explanation of Change

Shows an "Expense added" growl (with a "View" action) after an expense is created from FAB outside of its report‚ as well as when duplicating and splitting expenses on Spend. Removes the highlighting of new expenses in the Spend tab tables completely.

It's driven declaratively by a single ExpenseAddedGrowl component, which watches an Onyx signal that the creation flows write to (same as they did for highlighting). In the previous approach each creation flow triggered the growl and its navigation imperatively, passing values that could go stale before the user tapped "View". Centralizing it in one Onyx-driven component removes that duplication and the stale-data problem.

Fixed Issues

$ #91408
PROPOSAL: N/A

Tests

  1. Growl + "View" from global create (Inbox tab)

    • Go to the Inbox tab.
    • Tap the green + (FAB) button → Create expense.
    • Enter an amount → tap Next → select a workspace/participant → tap Next.
    • On the confirmation page, tap Create expense.
    • Verify a green "Expense added" growl with a "View" button appears.
    • Repeat the steps above for each expense type in the Create expense flow - Manual, Scan (upload a receipt), Distance (add waypoints), and Per diem (on a workspace with per-diem rates enabled).
  2. Growl in the Spend tab

    • Go to a different tab than Inbox.
    • Tap the + (FAB) → Create expense → enter an amount → Next → select a workspace/participant → Next → Create expense.
    • Verify the app lands on the Spend tab, and the same growl + working View appears there. The rows in the table should not be highlighted anymore.
  3. "View" opens the correct destination for the current surface

    • Spend (or any non-Inbox) tab: the new expense's details open in a right-hand panel over the Spend view.
    • Inbox, narrow layout: opens the thread as a full-screen report.
    • Inbox, wide, report with a single expense: the new expense's details open directly in the right-hand panel.
    • Inbox, wide, report with multiple expenses: opens the expense report super-wide with the new expense's thread RHP stacked on top.
    • Inbox, wide, tracked/self-DM expense (no expense report): opens the thread as a full-screen report.
    • With an expense/report already open in the RHP: View replaces it (does not stack a second RHP).
    • After the growl appears, switch to a different tab, then tap View: it navigates per the tab you're on now.
  4. Single growl/single navigation on a batch (skip-confirm multi-scan)

    • First, create one Scan expense for a recipient (FAB → Create expense → Scan → upload a receipt → Next → pick the recipient → Create expense) so the FAB shows a "Scan receipt" quick action for them.
    • Tap the FAB → Scan receipt quick action → add/upload 2 receipts and submit (this path has no confirmation page).
    • Verify navigation happens once (no flicker/double transition) and exactly one "Expense added" growl appears, for the last receipt of the batch.
    • Tap View and verify it opens the last created expense.
  5. Invoice

    • Tap the FAB → Send invoice (requires a workspace with Invoices enabled under More features).
    • Enter an amount → Next → pick a recipient → Next → Send invoice.
    • Verify the growl reads "Invoice sent" and its View button works.
  6. Split an existing expense into multiple

    • Open an existing expense → tap the ⋮ (more) menu → Split expense.
    • Split it into 2+ expenses and confirm.
    • Verify one "Expense added" growl appears (for the last split transaction); View opens that expense.
  7. Duplicate an expense

    • From the expense view: open an expense → ⋮ (more) → Duplicate.
    • From the Spend table: select 2+ transactions (checkboxes) → "n selected" dropdown → Duplicate expenses.
    • In each case verify one growl appears; View opens the (last) duplicated expense.
  8. Self-DM expense

    • Tap the FAB → Create expense → enter an amount → Next → select your own account (self-DM) as the recipient → Create expense.
    • Verify the growl appears; View opens the transaction thread as a full-screen report (not an RHP).
    • Afterward, open your self-DM chat, tap the same expense preview, and verify it opens correctly.
  9. Share flow (native only)

    • From another app, Share an image into Expensify → choose submit expense → fill details → submit.
    • Verify a single "Expense added" growl appears after submission with a working View, and navigation happens once.

Offline tests

  • Go offline, then create an expense from the FAB on the Inbox tab (Create expense → amount → Next → participant → Next → Create expense).
  • Verify the "Expense added" growl still appears and View opens the optimistic transaction thread.
  • While offline on the Spend tab, create another expense; verify the list refetches once after you go back online.

QA Steps

Same as tests.

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 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 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)
  • 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)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Nagranie.z.ekranu.2026-07-23.o.18.05.47.mov
Nagranie.z.ekranu.2026-07-23.o.18.29.15.mov
Android: mWeb Chrome
iOS: Native
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-07-21.at.17.04.37.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
Nagranie.z.ekranu.2026-07-20.o.16.46.23.mov
Nagranie.z.ekranu.2026-07-20.o.16.51.38.mov

@melvin-bot

melvin-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

Hey, I noticed you changed src/languages/en.ts in a PR from a fork. For security reasons, translations are not generated automatically for PRs from forks.

If you want to automatically generate translations for other locales, an Expensify employee will have to:

  1. Look at the code and make sure there are no malicious changes.
  2. Run the Generate static translations GitHub workflow. If you have write access and the K2 extension, you can simply click: [this button]

Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running:

npx ts-node ./scripts/generateTranslations.ts --help

Typically, you'd want to translate only what you changed by running npx ts-node ./scripts/generateTranslations.ts --compare-ref main

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/GlobalModals.tsx 100.00% <ø> (ø)
src/ONYXKEYS.ts 100.00% <ø> (ø)
src/components/Search/ChatSearchView.tsx 100.00% <ø> (ø)
src/components/Search/ExpenseFlatSearchView.tsx 100.00% <ø> (ø)
src/components/Search/ExpenseGroupedSearchView.tsx 65.06% <ø> (+4.84%) ⬆️
src/components/Search/ExpenseReportSearchView.tsx 100.00% <ø> (ø)
...h/SearchList/ListItem/TransactionGroupListItem.tsx 76.62% <100.00%> (-0.30%) ⬇️
src/components/Search/TaskSearchView.tsx 100.00% <ø> (ø)
src/components/Search/hooks/useSearchSnapshot.ts 88.75% <100.00%> (+1.10%) ⬆️
src/components/Search/index.tsx 45.94% <100.00%> (-0.19%) ⬇️
... and 24 more
... and 8 files with indirect coverage changes

@JakubKorytko JakubKorytko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swapping the imperative per-flow growl calls for a single declarative ExpenseAddedGrowl component that subscribes to Onyx is a solid improvement over the old approach! the comments are mostly nits. The batch-ordering one and the signal-lifecycle one are the two I would actually confirm before merge

Comment thread src/components/Search/index.tsx Outdated
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useSaveSortedReportIDs from '@hooks/useSaveSortedReportIDs';
import useSearchHighlightAndScroll from '@hooks/useSearchHighlightAndScroll';
import useSearchAutoRefetch from '@hooks/useSearchHighlightAndScroll';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the hook is now useSearchAutoRefetch, but the file (and its test) are still named useSearchHighlightAndScroll. Could we rename the file to useSearchAutoRefetch.ts so it matches the hook and is easier to find?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, definitely, but I'll rename it after the review, so the diff is easier to read. github shows the files as deleted and newly created after rename

Comment thread src/components/ExpenseAddedGrowl.tsx Outdated
Comment thread src/components/ExpenseAddedGrowl.tsx
Comment thread src/components/ExpenseAddedGrowl.tsx
Comment thread src/components/ExpenseAddedGrowl.tsx
Comment thread src/components/ExpenseAddedGrowl.tsx
Comment thread src/libs/Navigation/helpers/navigateAfterExpenseCreate.ts Outdated
Comment thread src/components/Search/SearchList/ListItem/ChatListItem.tsx
@mhawryluk
mhawryluk marked this pull request as ready for review July 21, 2026 15:07
@mhawryluk
mhawryluk requested review from a team as code owners July 21, 2026 15:07
@melvin-bot
melvin-bot Bot requested review from JmillsExpensify and situchan and removed request for a team July 21, 2026 15:07
@melvin-bot

melvin-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

@situchan Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@mountiny

Copy link
Copy Markdown
Contributor

@situchan can you review please?

@github-actions

Copy link
Copy Markdown
Contributor

🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here.

@situchan

situchan commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (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 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)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
web1.mov
web2.mov
web3.mov
web3-2.mov
web4.mov
web6.mov
web7.mov
web8.mov

@JmillsExpensify JmillsExpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BIg fan of this. LGTM

@situchan

situchan commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Is it expected not show growl when add new expense to existing report with multiple expenses?

And as you see video, highlighting the row still happens.

Screen.Recording.2026-07-27.at.9.27.52.PM.mov

Comment thread src/hooks/useSearchAutoRefetch.ts
Comment thread src/components/ExpenseAddedGrowl.tsx Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 62419b62d7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/libs/Navigation/helpers/navigateAfterExpenseCreate.ts Outdated
Comment thread src/GlobalModals.tsx
Comment on lines 53 to +54
<GrowlNotification ref={growlRef} />
<ExpenseAddedGrowl />

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Coordinate the expense toast with the existing growl host

This mounts a second, independently managed GrowlNotificationContent alongside the existing singleton growl. On narrow layouts both use the same fixed top anchor, so if an existing Growl.error() is shown during the expense toast—for example from the tab-navigation error path—the two notifications overlap and neither replaces or dismisses the other, obscuring text and touch targets. Route this notification through the shared growl host or otherwise serialize the two sources.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's technically true, but in practice this will not happen currently - we very rarely show the imperative growl errors, and not when creating new expenses. and I don't think it's worth adding synchronization of the two growl mechanisms at this moment, I think this can be handled if we do end up using growls in more scenarios, which would cause the overlap. right now it would complicate the code and fix an issue that is not present and might never be

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Review — this is a supplementary pass; the PR is already approved and has had thorough review from JakubKorytko, situchan, and JmillsExpensify. Overall the declarative, Onyx-driven approach is a clean improvement over the imperative #94866 design — centralizing the growl in one component removes the stale-data problem and the per-flow duplication. The signal is correctly wired into every creation path I traced (requestMoney, trackExpense, per-diem, invoice, split, split-update, duplicate, share), each guarded appropriately (e.g. isFromGlobalCreate for requestMoney). A few small things below — none blocking.

1. Independent rapid creations can swallow a growl. In ExpenseAddedGrowl.tsx:64-91 the effect waits for the latest signaled transaction to land, then clears all pending signal IDs but shows a growl only for the last one. For a real batch (multi-scan) that's exactly right — only the last transaction is signaled, so there's one entry. But if a user creates two independent FAB expenses in quick succession (both signaled before the first's deferred write flushes), signal holds {A, B}, and A's growl is silently dropped when B lands. It's a narrow race and a behavior change from the old per-flow growls (which fired for both). Probably acceptable given the deferral window is short — worth a one-line comment noting the intentional "only the newest survives" semantics so it isn't read as a bug later.

2. useSearchHighlightAndScrolluseSearchAutoRefetch rename still pending. Both JakubKorytko and situchan flagged the file/test name no longer matching the hook. mhawryluk confirmed the rename is deferred to after review so the diff stays readable — just make sure it actually lands before merge, since the diff-readability reason expires at that point.

3. Idle ..._undefined subscriptions. As situchan noted, when idle transactionID/hostReportID are undefined, so line 43 and line 53 subscribe to transactions_undefined / reportActions_undefined on a permanently-mounted component. Functionally harmless, but easy to skip with a transactionID ? \${...}${transactionID}` : undefined guard (useOnyxtreatsundefined` key as no-op).

4. Confirm the removed-highlight cleanup is complete. This PR removes row highlighting in the Spend tab and switches shouldHighlight to a hardcoded false in the list items (ChatListItem.tsx etc., already discussed). Worth a final grep to confirm no now-dead useAnimatedHighlightStyle/highlight props linger across the ~15 touched Search list files, since dead highlight plumbing is easy to leave behind in a broad removal.

The .at(-1) insertion-order reliance, lingering-on-rollback signal entries, and the missing key on GrowlNotificationContent were all already raised and addressed. Nice work — the centralization reads well and the inline comments explaining the non-obvious navigation branches (self-DM vs single-vs-multi-transaction report) are genuinely helpful.

@mhawryluk

Copy link
Copy Markdown
Member Author

Is it expected not show growl when add new expense to existing report with multiple expenses?

And as you see video, highlighting the row still happens.

Screen.Recording.2026-07-27.at.9.27.52.PM.mov

yes, that's intentional, here is the discussion: #91214 (comment)

@mhawryluk

Copy link
Copy Markdown
Member Author

1. Independent rapid creations can swallow a growl.

I added a comment.

2. useSearchHighlightAndScrolluseSearchAutoRefetch rename still pending.

Renamed ✅

3. Idle ..._undefined subscriptions.

Fixed by separating the component into two: ExpenseAddedGrowl and ExpenseAddedGrowlContent

4. Confirm the removed-highlight cleanup is complete.

Confirmed. I found one outdated comment and updated it.

@mhawryluk

Copy link
Copy Markdown
Member Author

@situchan I addressed the review comments, over to you

@mhawryluk
mhawryluk requested a review from situchan July 28, 2026 10:43
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.

6 participants