[Part 2] Onyx.connect() removal for ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS in ReportUtils.ts#79832
[Part 2] Onyx.connect() removal for ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS in ReportUtils.ts#79832ShridharGoel wants to merge 89 commits into
Conversation
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@DylanDylann 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] |
…ect2.2 # Conflicts: # src/components/Search/index.tsx # src/hooks/useDeleteTransactions.ts # src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx # src/pages/OnboardingWorkspaces/BaseOnboardingWorkspaces.tsx
|
Kindly bump on #79832 (comment) |
…ect2.2 # Conflicts: # src/components/Search/index.tsx
|
Updated |
…ect2.2 # Conflicts: # src/components/MoneyRequestHeaderSecondaryActions.tsx # src/components/Search/index.tsx # src/hooks/useDeleteTransactions.ts # src/libs/ReportSecondaryActionUtils.ts # tests/unit/ReportSecondaryActionUtilsTest.ts
| selectedTransactions, | ||
| email ?? '', | ||
| accountID, | ||
| archivedReportsIDSet, |
There was a problem hiding this comment.
Why do we need to pass archivedReportsIDSet here?
There was a problem hiding this comment.
It is used downstream by mapTransactionItemToSelectedEntry when calculating canChangeReport. That calls canEditFieldOfMoneyRequest, which needs archivedReportsIDSet to exclude archived reports from outstanding report checks without using Onyx.connect.
|
@ShridharGoel Could you review the change again before requesting review? |
|
@DylanDylann It's ready for review |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f17391f966
ℹ️ 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".
|
|
||
| // Unreported transaction from OldDot can have the reportID as an empty string | ||
| const isUnreportedExpense = !transaction?.reportID || transaction?.reportID === CONST.REPORT.UNREPORTED_REPORT_ID; | ||
| const archivedReportIDs = archivedReportsIDSet ?? buildArchivedReportsIDSet(allReportNameValuePair); |
There was a problem hiding this comment.
Avoid rebuilding archived sets for unrelated edits
When archivedReportsIDSet is omitted, this scans the entire report-name-value-pairs collection before knowing whether archive status is needed. Callers such as canEditMultipleTransactions() still invoke canEditFieldOfMoneyRequest() without the set while checking AMOUNT/MERCHANT/etc., so bulk-selecting many expenses can now do an O(number of selected transactions × number of reports) rebuild even though those fields never use archivedReportIDs. Move this fallback into the REPORT branch (or pass a prebuilt set from the caller) so non-report edit checks keep their previous constant-time behavior.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
@MelvinBot Are we necessary to pass the full archivedReportsIDSet in the canEditFieldOfMoneyRequest function?
There was a problem hiding this comment.
@ShridharGoel Could you check this codex's comment?
|
Yes, the full |
|
@MelvinBot Could you also review this PR? |
|
Here's my review of the PR: Overall: The migration from 1. Missing
|
|
@ShridharGoel Kindly bump on #79832 (comment) |
@DylanDylann Which comment is that? No comment is getting highlighted on clicking the link |
| function getOutstandingReportsForUser( | ||
| policyID: string | undefined, | ||
| reportOwnerAccountID: number | undefined, | ||
| archivedReportsIDSet?: ArchivedReportsIDSet, |
There was a problem hiding this comment.
@ShridharGoel if this is temporary, please comment that it should be removed in the next PRs (also note the link to the issue)
There was a problem hiding this comment.
The ref link didn't work 😄 I commented gain
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 35524bf13f
ℹ️ 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".
| function useArchivedReportsIDSet(): ArchivedReportsIDSet { | ||
| const [reportNameValuePairs] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS); | ||
|
|
||
| return buildArchivedReportsIDSet(reportNameValuePairs); |
There was a problem hiding this comment.
Avoid treating unloaded archive data as empty
When useOnyx has not delivered REPORT_NAME_VALUE_PAIRS yet, this returns an empty Set instead of an unloaded/undefined value. New callers pass that set into isReportOutstanding, whose fallback to the module-scoped allReportNameValuePair only runs when the set argument is omitted, so archived expense reports can be treated as outstanding in initial renders such as the report picker or move-expense eligibility until this hook catches up.
Useful? React with 👍 / 👎.
Explanation of Change
Here, we are passing archived‑report info into IOU/report selection and edit logic, and into search selection, so archived chats are consistently filtered and edit actions don’t target archived reports. We also remove the old
Onyx.connectcall since now all callers use the new hook‑based data.Fixed Issues
$ #66422
PROPOSAL:
Tests
#adminsand the tasks should show.Offline tests
QA Steps
Sanity testing should be enough. Everything should work as before.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, 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.ScrollViewcomponent to make it scrollable when more elements are added to the page.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
Screen.Recording.2026-02-21.at.3.20.08.PM.mov