Repository navigation
perf: optimize ManualOpenCreateExpense with policy selector and reduced subscriptions #84286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c9f3d85
afd63ef
ac68bdf
635cbe3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -160,7 +160,6 @@ function IOURequestStepConfirmation({ | |
| const draftPolicyID = getIOURequestPolicyID(initialTransaction, reportDraft); | ||
| const [policyDraft] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_DRAFTS}${draftPolicyID}`); | ||
| const [policyReal] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${realPolicyID}`); | ||
| const [reportDrafts] = useOnyx(ONYXKEYS.COLLECTION.REPORT_DRAFT); | ||
| const [gpsDraftDetails] = useOnyx(ONYXKEYS.GPS_DRAFT_DETAILS); | ||
| const [betas] = useOnyx(ONYXKEYS.BETAS); | ||
|
|
||
|
|
@@ -312,9 +311,9 @@ function IOURequestStepConfirmation({ | |
| const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${participant.reportID}`]; | ||
| return participant.accountID | ||
| ? getParticipantsOption(participant, personalDetails) | ||
| : getReportOption(participant, privateIsArchived, policy, currentUserPersonalDetails.accountID, personalDetails, reportAttributesDerived, reportDrafts); | ||
| : getReportOption(participant, privateIsArchived, policy, currentUserPersonalDetails.accountID, personalDetails, reportAttributesDerived); | ||
| }) ?? [], | ||
| [transaction?.participants, iouType, personalDetails, reportAttributesDerived, reportDrafts, privateIsArchivedMap, policy, currentUserPersonalDetails.accountID], | ||
| [transaction?.participants, iouType, personalDetails, reportAttributesDerived, privateIsArchivedMap, policy, currentUserPersonalDetails.accountID], | ||
|
Comment on lines
+314
to
+316
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Dropping Useful? React with 👍 / 👎.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This removal was intentional (originally done by @OlimpiaZurek in the first draft).
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@BartekObudzinski That goes against our efforts to remove impure functions. We should not rely on the module level onyx.connect in this case. Can you please raise a revert as we will eventually remove the module level subscription |
||
| ); | ||
| const isPolicyExpenseChat = useMemo(() => participants?.some((participant) => participant.isPolicyExpenseChat), [participants]); | ||
| const shouldGenerateTransactionThreadReport = !isBetaEnabled(CONST.BETAS.NO_OPTIMISTIC_TRANSACTION_THREADS); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ CONSISTENCY-3 (docs)
This
Tab.setSelectedTab(CONST.TAB.IOU_REQUEST_TYPE, newIouType)call is redundant.OnyxTabNavigatoralready callsTab.setSelectedTab(id, newSelectedTab)in itsscreenListeners.statehandler (OnyxTabNavigator.tsx line 190) before invoking theonTabSelectedcallback (line 192). This means by the timeonTabSelectedruns, the Onyx key is already updated. The duplicate call triggers a secondOnyx.mergefor the same key with the same value on every tab switch, which is unnecessary work.Remove the
Tab.setSelectedTabcall fromonTabSelectedsinceOnyxTabNavigatoralready handles persisting the selected tab:Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch — removed the duplicate
Tab.setSelectedTabcall.OnyxTabNavigatoralready persists the selected tab before invokingonTabSelected, so our call was redundant.