-
Notifications
You must be signed in to change notification settings - Fork 4k
[HOLD for Part 2.2] [Part 2.3] Remove Onyx.connect(ONYXKEYS.SESSION) in ReportActionsUtils: thread currentUserAccountID through isWhisperActionTargetedToOthers #96615
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ import Navigation, {navigationRef} from '@libs/Navigation/Navigation'; | |
| import TransitionTracker from '@libs/Navigation/TransitionTracker'; | ||
| import {isMoneyRequest, isMoneyRequestReport, isOneTransactionReport} from '@libs/ReportUtils'; | ||
|
|
||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import type {Route} from '@src/ROUTES'; | ||
| import ROUTES from '@src/ROUTES'; | ||
|
|
@@ -47,6 +48,14 @@ Onyx.connectWithoutView({ | |
|
|
||
| let allReports: OnyxCollection<Report>; | ||
|
|
||
| let sessionAccountID: number | undefined; | ||
| Onyx.connectWithoutView({ | ||
|
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. Please add a comment explaining why using |
||
| key: ONYXKEYS.SESSION, | ||
| callback: (value) => { | ||
| sessionAccountID = value?.accountID; | ||
| }, | ||
| }); | ||
|
|
||
| const allReportActions: OnyxCollection<ReportActions> = {}; | ||
| // Report actions are cached only to resolve parent actions for IOU cleanup; no UI subscribes, so connectWithoutView() is used. | ||
| Onyx.connectWithoutView({ | ||
|
|
@@ -60,7 +69,7 @@ Onyx.connectWithoutView({ | |
| }, | ||
| }); | ||
|
|
||
| function replaceOptimisticReportWithActualReport(report: Report, draftReportComment: string | undefined) { | ||
| function replaceOptimisticReportWithActualReport(report: Report, draftReportComment: string | undefined, currentUserAccountID: number) { | ||
| const {reportID, preexistingReportID, parentReportID, parentReportActionID} = report; | ||
|
|
||
| if (!reportID || !preexistingReportID) { | ||
|
|
@@ -215,7 +224,7 @@ function replaceOptimisticReportWithActualReport(report: Report, draftReportComm | |
| // betas is safe to pass as undefined because introSelected is undefined, so the code path | ||
| // that uses betas is never reached. Passing it explicitly so the compiler flags this when | ||
| // betas becomes required. Refactor issue: https://github.com/Expensify/App/issues/66424 | ||
| openReport({reportID: parentReportID, introSelected: undefined, betas: undefined, hasReportActions}); | ||
| openReport({reportID: parentReportID, introSelected: undefined, betas: undefined, hasReportActions, currentUserAccountID}); | ||
| }); | ||
| } else { | ||
| callback(); | ||
|
|
@@ -224,7 +233,7 @@ function replaceOptimisticReportWithActualReport(report: Report, draftReportComm | |
| // betas is safe to pass as undefined because introSelected is undefined, so the code path | ||
| // that uses betas is never reached. Passing it explicitly so the compiler flags this when | ||
| // betas becomes required. Refactor issue: https://github.com/Expensify/App/issues/66424 | ||
| openReport({reportID: parentReportID, introSelected: undefined, betas: undefined, hasReportActions}); | ||
| openReport({reportID: parentReportID, introSelected: undefined, betas: undefined, hasReportActions, currentUserAccountID}); | ||
| } | ||
| return; | ||
| } | ||
|
|
@@ -257,7 +266,11 @@ Onyx.connectWithoutView({ | |
| continue; | ||
| } | ||
|
|
||
| replaceOptimisticReportWithActualReport(report, allReportDraftComments?.[`${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${report.reportID}`]); | ||
| replaceOptimisticReportWithActualReport( | ||
| report, | ||
| allReportDraftComments?.[`${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${report.reportID}`], | ||
| sessionAccountID ?? CONST.DEFAULT_NUMBER_ID, | ||
| ); | ||
| } | ||
| }, | ||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; | ||
|
|
||
| import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; | ||
| import useOnyx from '@hooks/useOnyx'; | ||
| import useReportIsArchived from '@hooks/useReportIsArchived'; | ||
|
|
||
|
|
@@ -93,6 +94,7 @@ function WithWritableReportOrNotFoundImpl<TProps extends WithWritableReportOrNot | |
| const [reportDraft] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_DRAFT}${route.params.reportID}`); | ||
| const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED); | ||
| const [betas] = useOnyx(ONYXKEYS.BETAS); | ||
| const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails(); | ||
| const isReportArchived = useReportIsArchived(report?.reportID); | ||
|
|
||
| const iouTypeParamIsInvalid = !Object.values(CONST.IOU.TYPE) | ||
|
|
@@ -104,7 +106,7 @@ function WithWritableReportOrNotFoundImpl<TProps extends WithWritableReportOrNot | |
| if (!!report?.reportID || !route.params.reportID || !!reportDraft || !isEditing) { | ||
| return; | ||
| } | ||
| openReport({reportID: route.params.reportID, introSelected, betas}); | ||
| openReport({reportID: route.params.reportID, introSelected, betas, currentUserAccountID}); | ||
|
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.
On cold starts or deep links into this edit flow, 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. There is no chance for this one to be appeared |
||
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| }, []); | ||
|
|
||
|
|
||
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.
When a logged-out user opens a report deep link, this captures
CONST.DEFAULT_NUMBER_IDbeforewaitForUserSignIn()completes;openReportFromDeepLink()later uses that same value in the Concierge fallback when the linked report is missing or inaccessible. Since this effect only depends onsessionMetadata.statusand the Link module's live session subscription was removed, the fallback can open/create Concierge for account0instead of the account that just signed in. Pass a live/ref-updated account ID or resolve it after sign-in rather than freezing the signed-out value here.Useful? React with 👍 / 👎.