Remove Onyx.connect() for the key: ONYXKEYS.COLLECTION.REPORT in OptionsListUtils.ts#78645
Conversation
…libs/OptionsListUtils.ts
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@alitoshmatov 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] |
…rom-optionslistutils.ts
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppreport-android.movAndroid: mWeb ChromeiOS: HybridAppreport-ios.mp4iOS: mWeb SafariMacOS: Chrome / Safarireport-web.mov |
|
@abzokhattab please fill the checklist |
|
yes in my list @danieldoglas sorry for the confusion. |
…rom-optionslistutils.ts
|
The PR is ready @alitoshmatov please take alook |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dabb99f408
ℹ️ 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".
alitoshmatov
left a comment
There was a problem hiding this comment.
Changes look good to me!
| const report = getReportOrDraftReport(reportID); | ||
| const chatReport = getReportOrDraftReport(report?.chatReportID); |
There was a problem hiding this comment.
@abzokhattab @alitoshmatov Why do we use getReportOrDraftReport? This function will be removed soon
There was a problem hiding this comment.
I notice you are introducing many new usages of getReportOrDraftReport function
There was a problem hiding this comment.
if u look closer, its used inside the Onyx.connect there is no way to get the report data inside the Onyx.connect other than getReportOrDraftReport
it will be all removed when this connect is removed
There was a problem hiding this comment.
For this case, are we moving Onyx.connect from here to another file (not remove them)? 😄 I think we should hold off until we remove Onyx.connect for ONYXKEYS.COLLECTION.REPORT_ACTIONS. I'd prefer to keep it separated and avoid using Onyx.connect across files
|
please fix the conflicts and I'll review/merge |
| @@ -2021,12 +2026,12 @@ function prepareReportOptionsForDisplay(options: Array<SearchOption<Report>>, co | |||
|
|
|||
| let isOptionUnread = option.isUnread; | |||
| if (shouldUnreadBeBold) { | |||
| const chatReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${report.chatReportID}`]; | |||
| const chatReport = getReportOrDraftReport(report.chatReportID); | |||
There was a problem hiding this comment.
@abzokhattab How about this? And other usage places of getReportOrDraftReport
There was a problem hiding this comment.
Please check this warning: https://expensify.slack.com/archives/C02NK2DQWUX/p1759913248186279
…rom-optionslistutils.ts
|
@abzokhattab Could you consider splitting this into a separate PR? The code changes are getting quite large |
| const userToInviteReportID = availableOptions?.userToInvite?.isPolicyExpenseChat ? availableOptions.userToInvite.reportID : undefined; | ||
| const [userToInviteExpenseReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(userToInviteReportID)}`, {canBeMissing: true}); | ||
| const [userToInviteChatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(userToInviteExpenseReport?.chatReportID)}`, {canBeMissing: true}); |
There was a problem hiding this comment.
I see this duplicated a few times. Can you write a custom hook for it instead?
There was a problem hiding this comment.
Good point, I agree we should create a hook to deduplicate the code
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8837797203
ℹ️ 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".
| */ | ||
| export default function useUserToInviteReports(userToInvite: SearchOptionData | null | undefined) { | ||
| const userToInviteReportID = userToInvite?.isPolicyExpenseChat ? userToInvite.reportID : undefined; | ||
| const [userToInviteExpenseReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(userToInviteReportID)}`, {canBeMissing: true}); |
There was a problem hiding this comment.
Read draft reports when resolving policy expense invitees
This hook now resolves policy expense chats only from ONYXKEYS.COLLECTION.REPORT, but this flow previously relied on getReportOrDraftReport() semantics that also include reportDraft_ entries. If the invite target is still optimistic/draft-only, userToInviteExpenseReport stays undefined, and downstream selectors pass incomplete data into getPolicyExpenseReportOption(...), which can render a broken/blank workspace option and incorrect participant metadata.
Useful? React with 👍 / 👎.
Reviewer Checklist
Screenshots/VideosScreen.Recording.2026-02-23.at.14.06.33.mov |
|
@abzokhattab A few minor comments. Please ping me for approval after you address them all. |
tgolen
left a comment
There was a problem hiding this comment.
This PR picked up quite a few conflicts.
…d chatReport to deps
…rom-optionslistutils.ts
f7b4bdb to
964ab04
Compare
|
@abzokhattab Please don't ever force-push to your branch once people have begun to review it.
|
|
Yes sorry i had those commits unverified so i had to repush |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 @tgolen 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/tgolen in version: 9.3.26-0 🚀
|
|
🚀 Deployed to production by https://github.com/puneetlath in version: 9.3.26-8 🚀
|

Explanation of Change
Fixed Issues
$ #66378
PROPOSAL:
Tests
Prerequisite: Log into an account that has existing chats and expense reports.
Offline tests
Same as tests
QA Steps
Same as tests
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
Screen.Recording.2026-01-16.at.15.43.55.mov
Android: mWeb Chrome
Screen.Recording.2026-01-16.at.15.48.09.mov
iOS: Native
Screen.Recording.2026-01-16.at.15.45.31.mov
iOS: mWeb Safari
Screen.Recording.2026-01-16.at.15.46.35.mov
MacOS: Chrome / Safari
Screen.Recording.2026-01-16.at.15.41.17.mov