Skip to content

Fix: Duplicates-Not here RHP opens when Admin clicks "Review duplicates" offline - #97906

Merged
neil-marcellini merged 11 commits into
Expensify:mainfrom
annaweber830:fix/97610-duplicate-issue
Aug 18, 2026
Merged

neil-marcellini merged 11 commits into
Expensify:mainfrom
annaweber830:fix/97610-duplicate-issue

Conversation

@annaweber830

@annaweber830 annaweber830 commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Offline, when an admin clicks Review duplicates on another member's report, the RHP shows "Hmm... it's not here".

The button found the transaction thread from the cached IOU action's childReportID and navigated straight there, without checking that we actually have that report. When an admin opens someone else's report, the action can carry a childReportID for a thread that was never saved on that device. DynamicReviewPage needs the thread's parentReportID and parentReportActionID to find the IOU action and its transaction. Online OpenReport fetches the missing thread, but offline nothing can, so we land on Not Found.

What I changed:

  • If the IOU action has a childReportID but the report isn't in Onyx, await setOptimisticTransactionThread() to build the thread with its parent report/action IDs before navigating. This is the actual fix.
  • setOptimisticTransactionThread() now returns the Onyx.merge() promise so we can await it, instead of navigating before subscribers have the report.
  • Pass transaction when creating a new thread, so the optimistic report gets the same context as a normal transaction thread.
  • If we're offline and the IOU action itself is missing, show FullPageOfflineBlockingView instead of Not Found. We can't rebuild the thread without it, and resolveDuplicates() skips the transaction anyway.
  • Small cleanup: get the IOU action once with getIOUActionForTransactionID() and read childReportID off it, instead of going through getThreadReportIDsForTransactions() and getIOUActionForReportID(). Same result, one lookup, and it reuses the reportActions the component already has.

So the button still works offline when the data is cached, and shows the normal offline page when it isn't.

Fixed Issues

$ #97610
PROPOSAL: #97610 (comment)

Tests

  1. Log in as an admin, create a Collect workspace, and invite a member
  2. As the member, go to the workspace chat
  3. Click "+" button near the composer - Create expense - Manual - create an expense
  4. Open the expense, click More - Add expense - Create expense - create an expense with the same amount, merchant, date, currency, and category
  5. As the admin, open the workspace chat
  6. Go offline
  7. Open the expense report
  8. Click "Resolve duplicates" button
  9. Verify that the "Not here" RHP is not shown after clicking "Review duplicates," and that the Admin can proceed with the flow offline.
  • Verify that no errors appear in the JS console

Offline tests

Same as test

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."

  1. Log in as an admin, create a Collect workspace, and invite a member
  2. As the member, go to the workspace chat
  3. Click "+" button near the composer - Create expense - Manual - create an expense
  4. Open the expense, click More - Add expense - Create expense - create an expense with the same amount, merchant, date, currency, and category
  5. As the admin, open the workspace chat
  6. Go offline
  7. Open the expense report
  8. Click "Resolve duplicates" button
  9. Verify that the "Not here" RHP is not shown after clicking "Review duplicates," and that the Admin can proceed with the flow offline.
  • 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
record-compressed.mp4

@codecov

codecov Bot commented Aug 5, 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%> (ø)
...derPrimaryAction/ReviewDuplicatesPrimaryAction.tsx 0.00% <0.00%> (ø)
... and 45 files with indirect coverage changes

@annaweber830
annaweber830 marked this pull request as ready for review August 5, 2026 21:00
@annaweber830
annaweber830 requested review from a team as code owners August 5, 2026 21:00
@melvin-bot
melvin-bot Bot requested review from bernhardoj and trjExpensify and removed request for a team August 5, 2026 21:00
@melvin-bot

melvin-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

@bernhardoj 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 August 5, 2026 21:00

@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: 940e77cb72

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

return;
}

const iouAction = getIOUActionForTransactionID(reportActions, duplicateTransaction.transactionID);

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 Use the full action collection to resolve duplicate IOUs

When the duplicate transaction's IOU action is not in the current paginated reportActions slice, this lookup returns undefined even if the action is already cached in the report action collection; useTransactionThreadData builds this prop from usePaginatedReportActions, while the previous fallback used getIOUActionForReportID() to search the full cached collection. In long or previously paged reports, clicking Review duplicates can therefore take the legacy fallback and create/navigate to a new optimistic thread/IOU action instead of the existing childReportID, which breaks the duplicate review context especially offline.

Useful? React with 👍 / 👎.

trjExpensify
trjExpensify previously approved these changes Aug 5, 2026

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

Pesky NotFound pages! 👍

@@ -162,6 +163,18 @@ function DynamicReviewPage() {
}, []),
);

if (isOffline && !reportAction?.reportActionID) {
return (
<ScreenWrapper testID="DynamicReviewPage">

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.

Let's not do this change

iouReportAction: iouAction,
transaction: duplicateTransaction,
});
threadID = createdTransactionThreadReport?.reportID;

@bernhardoj bernhardoj Aug 6, 2026 •

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.

  1. As mentioned before, please create a reusable function for this and MoneyRequestReportTransactionsNavigation

// We know that the next thread report exists, it just wasn't fetched to Onyx yet, so we set it optimistically.
if (!nextThreadReport && nextThreadReportID) {
setOptimisticTransactionThread(nextThreadReportID, nextParentReport?.reportID, nextParentReportAction?.reportActionID, nextParentReport?.policyID);
}
// The transaction thread doesn't exist yet, so we should create it
if (!nextThreadReportID) {
const transactionThreadReport = createTransactionThreadReport({
introSelected,
currentUserLogin: currentUserEmail ?? '',
currentUserAccountID,
betas,
iouReport: nextParentReport,
iouReportAction: nextParentReportAction,
transaction: nextTransaction,
});
navigationParams.reportID = transactionThreadReport?.reportID;
}
// Wait for the next frame to ensure Onyx has processed the optimistic data updates from setOptimisticTransactionThread or createTransactionThreadReport before navigating
requestAnimationFrame(() => startTransition(() => Navigation.setParams(navigationParams)));

  1. No need to await setOptimisticTransactionThread. If you really need to wait, use the same pattern as the above code. (Or let's use setNavigationActionToMicrotaskQueue since it's created for this purpose)
  2. Don't use getReportOrDraftReport. Use useOnyx + selector

onPress={async () => {
if (transactionThreadReportID) {
Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.TRANSACTION_DUPLICATE_REVIEW.getRoute(transactionThreadReportID)));
return;

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.

I don't like the early return here. It becomes duplicated with the last if.

if (threadID) navigate; return;
do something
if (threadID) navigate; return;

Let's revert to the previous one.

@annaweber830

Copy link
Copy Markdown
Contributor Author

Hi @bernhardoj thanks. I updated PR.

Comment thread src/libs/actions/Report/index.ts Outdated
@@ -8168,12 +8191,12 @@ function resolveConciergeDescriptionOptions(
*/
function setOptimisticTransactionThread(reportID?: string, parentReportID?: string, parentReportActionID?: string, policyID?: string) {
if (!reportID) {
return;
return Promise.resolve();

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.

No need returning promise anymore

),
);
const duplicateIOUAction = getIOUActionForReportID(moneyRequestReport?.reportID, duplicateTransaction?.transactionID);
const duplicateThreadReportID = duplicateIOUAction?.childReportID;

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.

Why do we use getIOUActionForReportID().childReportID instead of the previous getThreadReportIDsForTransactions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

getThreadReportIDsForTransactions looks up the childReportID from the reportActions we pass it, which is the paginated slice from usePaginatedReportActions. getIOUActionForReportID instead reads the full cached report actions (via getAllReportActions), so it still resolves the thread even when the IOU action is outside the currently loaded page — e.g. an older duplicate in a long report. Codex flagged the same thing on the paginated version, so I switched to the full-collection lookup to be safe.

Happy to go back to getThreadReportIDsForTransactions if you'd rather keep it paginated — just let me know.


if (threadID) {
Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.TRANSACTION_DUPLICATE_REVIEW.getRoute(threadID)));
const reportIDToNavigate = threadID;

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.

Why we store this in a variable?

Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.TRANSACTION_DUPLICATE_REVIEW.getRoute(threadID)));
const reportIDToNavigate = threadID;
// Navigate on the microtask queue so the optimistic transaction thread is committed to Onyx before we navigate.
setNavigationActionToMicrotaskQueue(() => Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.TRANSACTION_DUPLICATE_REVIEW.getRoute(reportIDToNavigate))));

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.

Let's use setNavigationActionToMicrotaskQueue from Navigation

);
const duplicateIOUAction = getIOUActionForReportID(moneyRequestReport?.reportID, duplicateTransaction?.transactionID);
const duplicateThreadReportID = duplicateIOUAction?.childReportID;
const [duplicateThreadReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(duplicateThreadReportID)}`);

@bernhardoj bernhardoj Aug 6, 2026 •

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.

Use a selector here to only return the reportID as boolean. (for threadReportExists)

@bernhardoj

bernhardoj commented Aug 6, 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 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
    • 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
    • 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 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
android.mweb.mp4
iOS: HybridApp
ios.mp4
iOS: mWeb Safari
ios.mweb.mp4
MacOS: Chrome / Safari
web.mp4
ww.mp4

@melvin-bot
melvin-bot Bot requested a review from neil-marcellini August 6, 2026 15:01
neil-marcellini
neil-marcellini previously approved these changes Aug 6, 2026

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

Looks good, but pls add an automated test covering the changes. You can do it now or in a follow up PR.

@annaweber830

Copy link
Copy Markdown
Contributor Author

Hi @bernhardoj @neil-marcellini I added test.

@bernhardoj

Copy link
Copy Markdown
Contributor

Tests LGTM

@bernhardoj

Copy link
Copy Markdown
Contributor

@neil-marcellini waiting to be merged

@annaweber830

Copy link
Copy Markdown
Contributor Author

Hi @bernhardoj what should I do?

@bernhardoj

Copy link
Copy Markdown
Contributor

I'll ping on Slack.

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

Good to go, thank you.

@neil-marcellini
neil-marcellini merged commit ac9de0a into Expensify:main Aug 18, 2026
35 of 36 checks passed
@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.

@github-actions

Copy link
Copy Markdown
Contributor

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

@OSBotify OSBotify mentioned this pull request Aug 18, 2026
66 tasks done
@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/neil-marcellini in version: 9.4.56-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 No help site changes required.

This PR is an internal bug fix, not a user-facing behavior or feature change. It corrects an offline edge case where the Not here RHP incorrectly appeared when an admin clicked Review duplicates on another member's report while offline. The fix optimistically materializes the transaction thread from the cached IOU action so the duplicate-review flow works offline when the data is cached (and shows the normal offline page when it isn't).

Because this only restores the already-intended behavior of the duplicate-review flow — with no new features, buttons, labels, tabs, or workflows — the existing help content is still accurate:

No draft docs PR was created since there are no help site changes to make.

@annaweber830, if you believe a help site update is still warranted here, let me know what behavior should be documented and I'll open a draft PR.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/Beamanator in version: 9.4.56-3 🚀

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