Skip to content

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

Closed
borys3kk wants to merge 33 commits into
Expensify:mainfrom
software-mansion-labs:borys3kk-introduce-growls-pr2
Closed

Confirm new expenses with a “View” toast on Spend instead of scrolling to and highlighting the row#94866
borys3kk wants to merge 33 commits into
Expensify:mainfrom
software-mansion-labs:borys3kk-introduce-growls-pr2

Conversation

@borys3kk

@borys3kk borys3kk commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Replaces the post-create Search row highlight with an "Expense added" / "Invoice sent" growl that has a "View" action deep-linking to the new expense's transaction thread RHP. The IOU actions (requestMoney/trackExpense/split/invoice/per-diem/distance) now solely own post-create navigation + feedback (batch-aware via isLastTransactionOfBatch), fixing double navigation/growls. Removes useSearchHighlightAndScroll (replaced by useSearchAutoRefetch, refetch-only) and the TRANSACTION_IDS_HIGHLIGHT_ON_SEARCH_ROUTE Onyx key.

Fixed Issues

$ #91408
PROPOSAL:

Tests

Test 1: Expense-added growl with working "View" link (global create from Inbox)

  1. Sign in and go to the Inbox tab.
  2. Press the global create (FAB) > Create expense, enter an amount, pick a workspace/participant, and submit from the confirmation page.
  3. Verify that a green "Expense added" growl appears with a "View" button.
  4. Press "View" and verify that the transaction thread RHP for the newly created expense opens (with the report visible underneath on wide layouts).
  5. Repeat starting from the Reports (Spend) tab and verify the app lands on the Expenses search page and the same growl with a working "View" link appears there.

Test 2: Single growl and single navigation on skip-confirm and multi-scan flows

  1. Seed the quick action: press the global create (FAB) > Create expense > Scan, upload a receipt, pick a recipient, and submit from the confirmation page. The FAB menu now shows a "Scan receipt" quick action for that recipient.
  2. Press the FAB > the "Scan receipt" quick action, and take/upload 2 receipts. The submit happens immediately with no confirmation page (this is the skip-confirmation path).
  3. Verify that navigation happens once (the scan modal dismisses with no flicker/double transition) and exactly ONE "Expense added" growl appears, after the last receipt of the batch.
  4. Press "View" and verify it opens the thread of the last created expense.
  5. Create an invoice via global create > Send invoice (requires a workspace with Invoices enabled under More features) and verify the growl says "Invoice sent" with a working "View" link.

Test 3: In-report add highlights the row instead of a growl; Share flow stays correct

  1. Open an existing expense report and add an expense to it from within the report.
  2. Verify that NO growl appears and the new row is highlighted in the report's transaction list.
  3. (Native) Share an image into Expensify (Share flow > submit expense details) and verify a single "Expense added" growl appears after submission, with a working "View" link, and navigation happens once.
  • Verify that no errors appear in the JS console

Offline tests

  1. Go offline, then create an expense from the global create button on the Inbox tab.
  2. Verify the "Expense added" growl still appears and "View" opens the optimistic transaction thread RHP.
  3. While on the Expenses search page offline, create another expense and verify the list refetches once you go back online (pending auto-refetch fires after reconnect).

QA Steps

Same as tests.

  • 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 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 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 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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@melvin-bot

melvin-bot Bot commented Jun 29, 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

@borys3kk
borys3kk force-pushed the borys3kk-introduce-growls-pr2 branch from 4754efa to 4af5484 Compare July 6, 2026 12:06
@codecov

codecov Bot commented Jul 6, 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/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% <ø> (ø)
src/components/Search/TaskSearchView.tsx 100.00% <ø> (ø)
src/components/Search/hooks/useSearchSnapshot.ts 88.60% <100.00%> (+1.10%) ⬆️
src/components/Search/index.tsx 46.00% <100.00%> (-0.20%) ⬇️
src/libs/ExportOnyxState/common.ts 80.35% <ø> (ø)
src/libs/IOUAmountSubmission.ts 76.79% <100.00%> (+0.65%) ⬆️
... and 25 more
... and 341 files with indirect coverage changes

borys3kk added 2 commits July 6, 2026 14:51
  - Fix multi-receipt batches firing navigation/growl once per receipt:
    createTransaction now threads isLastTransactionOfBatch into
    requestMoney/trackExpense so post-create feedback fires only on the
    final transaction
  - Forward backToReport from useExpenseSubmission into requestMoney so
    post-create navigation returns to the originating report
  - Narrow cleanupAfterSkipConfirmSubmit to cleanup-only
    (CleanupAfterExpenseCreateParams): the write action owns post-create
    navigation now, so the dispatcher must never navigate too; trim the
    dead navigation params from all skip-confirm call sites and drop the
    now-unused action/getExistingTransactionID plumbing from
    ScanRouter/ScanSkipConfirmation/distance navigation
  - Trim performPostBatchCleanup to {allTransactionsCreated} and remove
    the dead chat-target resolution from useExpenseSubmission
  - Remove the newSearchResultKeys highlight stamping from
    useSearchSnapshot and the shouldUseLiveData prop from
    useSearchAutoRefetch (both dead after the growl replaced the
    post-create highlight)
  - showExpenseAddedGrowl: clear the safety timeout once resolved, resolve
    immediately when there is no iouReportID to subscribe to, and drop the
    microtask deferral on the single-transaction inbox path
  - Update affected tests for the cleanup-only contract
borys3kk added 3 commits July 7, 2026 16:44
  - Remove the dead shouldNavigate param from navigateAfterExpenseCreate;
    its "feedback without navigation" job is fully owned by
    surfaceExpenseCreatedFeedback since the nav-ownership refactor
  - Resolve the growl View button's inbox/spend context at press time
    instead of freezing it at growl-show time (drop the isInbox param)
  - Delete the cleanupAfterSkipConfirmSubmit passthrough; call sites use
    cleanupAfterExpenseCreate directly
  - Restore backToReport on skip-confirm submits: createTransaction
    accepts and forwards it to requestMoney, AmountSubmission passes it -
    in-chat "Add expense" flows return to the originating chat again
  - Scope the per-iteration optimistic transaction id to the submit loops
    in useExpenseSubmission (the outer "last" variable was a leftover)
  - Rename the useSearchAutoRefetch params type to
    UseSearchAutoRefetchParams
  - Wire mockUseIsFocused into the navigation mock in
    useSearchAutoRefetchTest so the not-focused test actually exercises
    the focus branch

@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.

really good job! two medium-to-minor concerns, approved!

Comment thread src/libs/Navigation/helpers/navigateAfterExpenseCreate.ts Outdated
Comment thread src/pages/Share/SubmitDetailsPage.tsx Outdated
  showExpenseAddedGrowl: a provided transactionThreadReportID no longer skips
  the report-actions wait when an iouReportID exists - the thread ID arrives
  before the deferred API.write flushes, so View could open a thread not yet
  in Onyx. Fast path now requires no iouReportID or an already-present IOU
  action.

  Share flow: shouldHandleNavigation: false still surfaced the growl before
  SubmitDetailsPage navigated, and global-create paths could show it twice.
  Added shouldShowPostCreateFeedback (default true) so the page keeps the
  action silent while cleanupAndNavigateAfterExpenseCreate owns navigation
  and feedback. Also threaded iouReportID / transactionThreadReportID through
  the cleanup helper so the growl View deep link resolves.

  Also removes dead isTransactionMatchWithGroupItem from SearchUIUtils - this
  branch already deleted its only caller and its export, leaving an unused
  function that failed lint.
@borys3kk
borys3kk marked this pull request as ready for review July 8, 2026 12:00
@borys3kk
borys3kk requested review from a team as code owners July 8, 2026 12:00
@melvin-bot
melvin-bot Bot requested review from joekaufmanexpensify and situchan and removed request for a team July 8, 2026 12:00
@borys3kk
borys3kk marked this pull request as draft July 8, 2026 12:00
@melvin-bot
melvin-bot Bot removed the request for review from a team July 8, 2026 12:00
@melvin-bot

melvin-bot Bot commented Jul 8, 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]

@melvin-bot
melvin-bot Bot requested a review from a team July 8, 2026 12:00
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

This PR adds a new Onyx.connectWithoutView call, so I've requested a review from the Onyx performance reviewers (@tgolen, @mountiny, @luacmartins) — a review from any one of them is enough. Please add a link in your PR description to the Slack discussion where the @frontend-performance team approved using connectWithoutView here.

@borys3kk

borys3kk commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

currently recording videos, made the pr ready for review to run the AI reviews, converted back to draft
edit: I will also check if I really need the ConnectWithoutView

@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: ecb42ae7ca

ℹ️ 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/pages/Share/SubmitDetailsPage.tsx Outdated
Comment thread src/libs/actions/IOU/TrackExpense.ts Outdated
@mountiny
mountiny requested a review from Copilot July 8, 2026 14:28
@borys3kk borys3kk changed the title Borys3kk introduce growls pr2 Confirm new expenses with a “View” toast on Spend instead of scrolling to and highlighting the row Jul 13, 2026
borys3kk added 3 commits July 13, 2026 13:13
  Per-diem tracked to the self-DM now surfaces the "Expense added" growl on
  global create (and feedback on the orchestrator-owned path, which previously
  got nothing): submitPerDiemExpenseForSelfDM returns the transaction/thread
  IDs and the hook keeps its dismiss-to-self-DM navigation while matching the
  other flows feedback-wise.

  Defer transaction-thread materialization to "View" press time: showing the
  growl now only runs a pure resolvability check, and the context merge or
  optimistic thread creation (with its OpenReport write) happens in onPress -
  matching every other thread navigation entry point and keeping untapped
  growls free of Onyx/API side effects.

  Also: remove the now-dead resolveChatTargetForSubmitCleanup (and its test
  file and leftover mocks), cover the offline-stash -> reconnect fires-exactly-
  once path in useSearchAutoRefetchTest, and promote the growl safety timeout
  to CONST.TIMING.EXPENSE_ADDED_GROWL_SAFETY_TIMEOUT.
…ce-growls-pr2

# Conflicts:
#	src/components/Search/hooks/useSearchSnapshot.ts
@borys3kk

Copy link
Copy Markdown
Contributor Author

All automated review comments are resolved, @mhawryluk will take this PR over

Comment on lines +149 to +167
if (channel.onFlush) {
for (const cb of channel.onFlush) {
cb();
}
}
}

/**
* Run `callback` once the pending optimistic write has been applied to Onyx, after the next flush of the
* most-recently-registered active channel or immediately if nothing is pending.
* Used to sequence work that depends on the optimistic data existing.
*/
function runAfterDeferredWrite(callback: () => void) {
const channel = [...channels.values()].reverse().find((c) => !c.isReserved);
if (!channel) {
callback();
return;
}
channel.onFlush = [...(channel.onFlush ?? []), callback];

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.

This looks good to me as an interim step. runAfterDeferredWrite() without a key is not fully bulletproof as a generic primitive, since it relies on the latest non-reserved channel being the intended one. In this flow that should be OK because it is called synchronously right after the deferred write is registered.

I would avoid spreading this unkeyed pattern further, since the longer-term direction is to move this into an API-owned API.writeWhenReady(...) model: #96010

So I’m OK with this PR as long as this stays scoped to the current flow.

@borys3kk

Copy link
Copy Markdown
Contributor Author

closing this one, here's the current

@borys3kk borys3kk closed this Jul 21, 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.

7 participants