Skip to content

Fix legacy transaction self-heal being skipped when a report has no IOU action - #101162

Merged
blimpich merged 6 commits into
mainfrom
mollfpr-fix-blank-expense-legacy-backfill
Sep 24, 2026
Merged

blimpich merged 6 commits into
mainfrom
mollfpr-fix-blank-expense-legacy-backfill

Conversation

@mollfpr

@mollfpr mollfpr commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Before creating an optimistic IOU action and transaction thread for a legacy transaction, SearchMoneyRequestReportPage checks whether the current reportActions array is stale (leftover from a previously viewed report) by looking for an IOU-type action whose own reportID field matches reportIDFromRoute.

This works fine for a report that only has one action (CREATED), but once a report gets more actions before ever getting an IOU action or transaction thread (e.g. SUBMITTED, APPROVED, exported to CSV), the check always fails, since none of those actions are IOU-type. So the self-heal never runs for that report again, and the transaction stays invisible even though the data is fine.

This PR makes three changes in SearchMoneyRequestReportPage.tsx:

  1. The staleness check now uses getReportAction(reportID, reportActionID) instead of reading the action's own reportID field. It checks whether each action's ID actually exists in the current report's own reportActions collection, regardless of action type. A report can pass this check without ever having an IOU action, which is what unblocks the self-heal.
  2. getAllNonDeletedTransactions is now called with includeOrphanedTransactions: true, so a transaction with no matching IOU action isn't treated as if it were a deleted comment and filtered out.
  3. When the transaction isn't in the main Onyx collection yet and we fall back to the Search snapshot, the code used to grab the first transactions_-prefixed key in the snapshot and give up if it didn't belong to the current report, even if a matching one existed further in the snapshot. It now keeps looking until it finds the transaction that actually belongs to reportIDFromRoute.

Fixed Issues

$ #98053
PROPOSAL:

Tests

Prerequisite:

  • Account with a policy
  • In OldDot, import the personal card and choose reimbursable disable. Use Discover bank and account expensidemo, pass #USD. After the import, don't open the report
  1. Go to Spend > Reports page
  2. Click on the report checkbox and export CSV
  3. Open the report
  4. Verify the expense detail is shown
  • Verify that no errors appear in the JS console

Offline tests

N/A

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 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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.Sept.15.2026.mp4

@codecov

codecov Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
src/pages/Search/SearchMoneyRequestReportPage.tsx 85.40% <90.00%> (+85.40%) ⬆️
... and 935 files with indirect coverage changes

@mollfpr
mollfpr marked this pull request as ready for review September 15, 2026 09:23
@mollfpr
mollfpr requested review from a team as code owners September 15, 2026 09:23
@melvin-bot

melvin-bot Bot commented Sep 15, 2026

Copy link
Copy Markdown

@parasharrajat 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 request for a team September 15, 2026 09:23

@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: 735f5d130f

ℹ️ 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".

@mollfpr

mollfpr commented Sep 19, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

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

ℹ️ 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".

@mollfpr

mollfpr commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 260031bf28

ℹ️ 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".

@mollfpr

mollfpr commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

@parasharrajat it's ready for review! 🙌

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

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

🔲 MacOS / Chrome

23.09.2026_18.54.56_REC.mp4

🔲 Android / native

24.09.2026_18.57.33_REC.mp4

🎀 👀 🎀 C+ reviewed

@melvin-bot
melvin-bot Bot requested a review from blimpich September 24, 2026 13:29
@melvin-bot

melvin-bot Bot commented Sep 24, 2026

Copy link
Copy Markdown

@blimpich 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]

@blimpich
blimpich merged commit 6b01320 into main Sep 24, 2026
43 of 45 checks passed
@blimpich
blimpich deleted the mollfpr-fix-blank-expense-legacy-backfill branch September 24, 2026 19:14
@github-actions

Copy link
Copy Markdown
Contributor

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

@OSBotify

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.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/blimpich in version: 9.4.94-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site changes are needed for this PR, so I didn't create a docs PR.

This PR fixes a bug where an expense didn't appear on a report. It happened when the report got actions such as Submitted, Approved, or a CSV export before its expense was loaded. The fix only restores the expected behavior. It doesn't add or rename any feature, setting, tab, or button.

Details
  • Changed files: src/pages/Search/SearchMoneyRequestReportPage.tsx and its UI test. Both hold internal self-heal logic for legacy transactions.
  • I searched App/docs/articles for articles about expenses missing from reports. None describe this bug or the internal behavior this PR changes.

view run

@lanitochka17

Copy link
Copy Markdown

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

@mollfpr

mollfpr commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author

@lanitochka17 I just found out that we not extract any transactions when import personal card from staging, could you try to import from production then do the NewDot in staging?

@Julesssss

Copy link
Copy Markdown
Contributor

@mollfpr oh yeah I see that happening here and here.

I have asked QA to retest these test steps:

  1. Navigate to www.expensify.com (not via the switch to staging sitcher) and sign in with the test account
  2. Settings > Account > Wallet > Import Bank/Card. Choose Discover, sign in and disable reimbursable, then complete the flow
  3. Wait a few seconds for the scrape, then confirm on www.expensify.com/reports that the new report has expenses
  4. NOW go to staging.new.expensify.com > Spend > Reports. Do not open the report yet.
  5. Tick the report and export to CSV
  6. Open the report and verify the expense detail is shown

@mollfpr

mollfpr commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

@Julesssss yup, that’s seems right to me! Thank you!

@m-natarajan

Copy link
Copy Markdown

Not reproduced as per this steps #101162 (comment)

bandicam.2026-09-28.22-42-36-335.mp4

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/Julesssss in version: 9.4.94-0 🚀

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.

8 participants