Repository navigation
Fix: Duplicates-Not here RHP opens when Admin clicks "Review duplicates" offline - #97906
Conversation
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@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] |
There was a problem hiding this comment.
💡 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); |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Pesky NotFound pages! 👍
| @@ -162,6 +163,18 @@ function DynamicReviewPage() { | |||
| }, []), | |||
| ); | |||
|
|
|||
| if (isOffline && !reportAction?.reportActionID) { | |||
| return ( | |||
| <ScreenWrapper testID="DynamicReviewPage"> | |||
There was a problem hiding this comment.
Let's not do this change
| iouReportAction: iouAction, | ||
| transaction: duplicateTransaction, | ||
| }); | ||
| threadID = createdTransactionThreadReport?.reportID; |
There was a problem hiding this comment.
- As mentioned before, please create a reusable function for this and MoneyRequestReportTransactionsNavigation
- 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)
- Don't use getReportOrDraftReport. Use useOnyx + selector
| onPress={async () => { | ||
| if (transactionThreadReportID) { | ||
| Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.TRANSACTION_DUPLICATE_REVIEW.getRoute(transactionThreadReportID))); | ||
| return; |
There was a problem hiding this comment.
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.
|
Hi @bernhardoj thanks. I updated PR. |
| @@ -8168,12 +8191,12 @@ function resolveConciergeDescriptionOptions( | |||
| */ | |||
| function setOptimisticTransactionThread(reportID?: string, parentReportID?: string, parentReportActionID?: string, policyID?: string) { | |||
| if (!reportID) { | |||
| return; | |||
| return Promise.resolve(); | |||
There was a problem hiding this comment.
No need returning promise anymore
| ), | ||
| ); | ||
| const duplicateIOUAction = getIOUActionForReportID(moneyRequestReport?.reportID, duplicateTransaction?.transactionID); | ||
| const duplicateThreadReportID = duplicateIOUAction?.childReportID; |
There was a problem hiding this comment.
Why do we use getIOUActionForReportID().childReportID instead of the previous getThreadReportIDsForTransactions?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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)))); |
There was a problem hiding this comment.
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)}`); |
There was a problem hiding this comment.
Use a selector here to only return the reportID as boolean. (for threadReportExists)
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb Chromeandroid.mweb.mp4iOS: HybridAppios.mp4iOS: mWeb Safariios.mweb.mp4MacOS: Chrome / Safariweb.mp4ww.mp4 |
neil-marcellini
left a comment
There was a problem hiding this comment.
Looks good, but pls add an automated test covering the changes. You can do it now or in a follow up PR.
|
Hi @bernhardoj @neil-marcellini I added test. |
|
Tests LGTM |
…7610-duplicate-issue
…7610-duplicate-issue
…7610-duplicate-issue
|
@neil-marcellini waiting to be merged |
|
Hi @bernhardoj what should I do? |
|
I'll ping on Slack. |
neil-marcellini
left a comment
There was a problem hiding this comment.
Good to go, thank you.
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 neil-marcellini has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/neil-marcellini in version: 9.4.56-0 🚀
|
|
🤖 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. |
|
🚀 Deployed to production by https://github.com/Beamanator in version: 9.4.56-3 🚀
Bundle Size Analysis (Sentry): |
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
childReportIDand navigated straight there, without checking that we actually have that report. When an admin opens someone else's report, the action can carry achildReportIDfor a thread that was never saved on that device.DynamicReviewPageneeds the thread'sparentReportIDandparentReportActionIDto find the IOU action and its transaction. OnlineOpenReportfetches the missing thread, but offline nothing can, so we land on Not Found.What I changed:
childReportIDbut the report isn't in Onyx, awaitsetOptimisticTransactionThread()to build the thread with its parent report/action IDs before navigating. This is the actual fix.setOptimisticTransactionThread()now returns theOnyx.merge()promise so we can await it, instead of navigating before subscribers have the report.transactionwhen creating a new thread, so the optimistic report gets the same context as a normal transaction thread.FullPageOfflineBlockingViewinstead of Not Found. We can't rebuild the thread without it, andresolveDuplicates()skips the transaction anyway.getIOUActionForTransactionID()and readchildReportIDoff it, instead of going throughgetThreadReportIDsForTransactions()andgetIOUActionForReportID(). Same result, one lookup, and it reuses thereportActionsthe 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
Offline tests
Same as test
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
record-compressed.mp4