Skip to content

[Home Page] "Recently added" slot doesn't update after creating an expense while offline#94180

Merged
grgia merged 14 commits into
Expensify:mainfrom
software-mansion-labs:@adamgrzybowski/recently-added-offline
Jul 6, 2026
Merged

[Home Page] "Recently added" slot doesn't update after creating an expense while offline#94180
grgia merged 14 commits into
Expensify:mainfrom
software-mansion-labs:@adamgrzybowski/recently-added-offline

Conversation

@adamgrzybowski

Copy link
Copy Markdown
Contributor

Explanation of Change

  • The Home page "Recently added" slot is sourced from the user's expense Search snapshot, which is only refreshed by an online API call. As a result, an expense created while offline did not appear in the slot until the device came back online.
  • This change merges locally-created expenses that are still pending sync into the slot, deduped against the snapshot so a row never appears twice, so the section reflects optimistic data immediately.
  • Pending rows now render the standard offline pending (greyed-out) treatment, and reconcile cleanly once the expense syncs and the snapshot refreshes.

Fixed Issues

$ #94162
PROPOSAL:

Tests

Offline tests

QA Steps

  1. Open Home with an account that already has expenses.
  2. Turn off the network connection (go offline) and create a new expense.
  3. Verify the new expense appears at the top of the "Recently added" slot immediately, shown with the offline pending (greyed-out) treatment.
  4. Turn the network back on and verify the expense remains in the slot without duplicating.
  • 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
Screen.Recording.2026-06-22.at.14.58.10.mov

@adamgrzybowski adamgrzybowski requested review from a team as code owners June 22, 2026 13:57
@melvin-bot melvin-bot Bot requested review from ZhenjaHorbach and flaviadefaria and removed request for a team June 22, 2026 13:57
@melvin-bot

melvin-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

@ZhenjaHorbach 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 review from a team and grgia June 22, 2026 13:57
@melvin-bot

melvin-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

@grgia 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 removed the request for review from a team June 22, 2026 13:57

@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: 6f25290b41

ℹ️ 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/home/RecentlyAddedSection/useRecentlyAddedData.ts Outdated
An offline-created personal tracked expense is absent from the Search
snapshot, so its transaction thread couldn't be resolved and the
Recently added row navigated to report "0". Fall back to local report
actions to find the IOU action's childReportID when the snapshot has
no thread yet.
@adamgrzybowski

Copy link
Copy Markdown
Contributor Author

FYI I need to add support for deleting

@adamgrzybowski

Copy link
Copy Markdown
Contributor Author

It works now 🤷
image

@grgia

grgia commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

@adamgrzybowski can you merge main for tests?

@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/libs/TransactionThreadNavigationUtils.ts 100.00% <100.00%> (ø)
...ges/home/RecentlyAddedSection/RecentlyAddedRow.tsx 100.00% <100.00%> (ø)
.../home/RecentlyAddedSection/useRecentlyAddedData.ts 89.85% <92.85%> (+3.18%) ⬆️
... and 82 files with indirect coverage changes

grgia
grgia previously approved these changes Jun 26, 2026
@adamgrzybowski

Copy link
Copy Markdown
Contributor Author

@ZhenjaHorbach let's move it forward to avoid merge conflicts

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

Will check soon!

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

I suppose the removed expense shouldn't be clickable

2026-06-29.15.49.36.mov

@ZhenjaHorbach

ZhenjaHorbach commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Looks like we don't hide the original expense after creating splits
I suppose we need to add a filter for this case

2026-06-29.15.54.40.mov
Снимок экрана — 2026-06-29 в 16 01 32

Comment thread src/libs/ReportActionsUtils.ts Outdated
A deleted expense in the Recently added section stayed clickable while
offline since OfflineWithFeedback only strikes the row through. Make the
row's onPress a no-op and show the default cursor when the expense is
pending deletion.
Prefer the local transactions_ copy so an offline edit's updated values
and pendingFields drive the row, rendering the offline pending treatment
for edits (UPDATE) alongside creates (ADD) and deletes (DELETE).
Splitting reassigns the original transaction to the synthetic SPLIT_REPORT_ID
and adds the split children as new expenses, but the slot still surfaced the
orphaned original alongside the splits. Filter out transactions whose effective
reportID is SPLIT_REPORT_ID, preferring the local copy so it works before the
snapshot refreshes (offline splits).
@ZhenjaHorbach

ZhenjaHorbach commented Jul 1, 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
2026-07-01.14.30.30.mov
Android: mWeb Chrome
2026-07-01.14.32.56.mov
iOS: HybridApp
2026-07-01.14.30.30.mov
iOS: mWeb Safari
2026-07-01.14.32.56.mov
MacOS: Chrome / Safari
2026-07-01.14.23.25.mov

@ZhenjaHorbach

ZhenjaHorbach commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

LGTM
@adamgrzybowski
But can you check lint issues please?

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

Still have lint issues

@melvin-bot melvin-bot Bot requested a review from grgia July 1, 2026 16:19
Comment thread src/libs/ReportActionsUtils.ts Outdated
grgia
grgia previously approved these changes Jul 2, 2026

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

NAB comment but please take a look before we merge @adamgrzybowski

…ll report actions

Addresses PR review comment: reuse getIOUActionForReportID(findSelfDMReportID(), ...) and remove the getThreadReportIDForTransaction helper and its tests.
@grgia grgia merged commit 0f427c7 into Expensify:main Jul 6, 2026
35 checks passed
@OSBotify

OSBotify commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

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

@OSBotify

OSBotify commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/grgia in version: 9.4.28-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

Help site review — no docs changes required

I reviewed this PR against the help site articles under docs/articles, and no help site changes are needed. I did not create a draft docs PR.

Why: This is an offline-sync bug fix, not a change to any user-facing feature, setting, tab, or button. It makes an expense created while offline appear in the Home Recently added section immediately (rendered with the standard offline pending / greyed-out treatment) and reconcile without duplicating once it syncs.

The relevant help article — Expensify-Home-Overview.md — already describes the intended behavior:

The Recently added section shows your most recently added expenses, so you can quickly get back to what you just created or imported.

This fix simply makes that documented behavior hold true offline as well. Nothing in the article contradicts the new behavior, so there's no stale copy to correct.

The greyed-out "pending" treatment for offline-created rows is the same app-wide OfflineWithFeedback pattern used across other transaction lists, and Expensify help articles don't document that transient per-list treatment. Adding it here would be inconsistent with existing help content.

Files reviewed in this PR
  • src/libs/TransactionThreadNavigationUtils.ts — thread resolution fallback for optimistic expenses
  • src/pages/home/RecentlyAddedSection/RecentlyAddedRow.tsx — wraps rows in OfflineWithFeedback
  • src/pages/home/RecentlyAddedSection/useRecentlyAddedData.ts — merges/dedupes locally-pending expenses into the slot
  • tests/unit/HomePage/RecentlyAddedSection/useRecentlyAddedDataTest.ts — unit tests

None introduce or rename a user-facing feature, setting, or workflow.

adamgrzybowski, if you believe the offline behavior of the Recently added section should be explicitly documented (e.g. a short FAQ entry), reply with @MelvinBot and I'll draft a docs PR for it.

@lanitochka17

Copy link
Copy Markdown

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

@OSBotify

OSBotify commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 9.4.28-2 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

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