From 1bf6e4f6c0f3f919346f393b0dfc0eabb5ded780 Mon Sep 17 00:00:00 2001 From: Andrii Vitiv Date: Tue, 10 Sep 2024 14:44:51 +0300 Subject: [PATCH] Fix crash when switching accounts (again) --- src/pages/home/ReportScreen.tsx | 10 ++++++++-- src/pages/home/report/ReportActionItem.tsx | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 4491a12e6bb..cfdd785ab92 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -121,7 +121,7 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {allowStaleData: true, initialValue: {}}); const [betas] = useOnyx(ONYXKEYS.BETAS); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const [parentReportAction] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportOnyx?.parentReportID || 0}`, { + const [parentReportAction] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportOnyx?.parentReportID || -1}`, { canEvict: false, selector: (parentReportActions) => getParentReportAction(parentReportActions, reportOnyx?.parentReportActionID ?? ''), }); @@ -389,8 +389,14 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro */ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const isLoading = isLoadingApp || !reportIDFromRoute || (!isSidebarLoaded && !isInNarrowPaneModal) || PersonalDetailsUtils.isPersonalDetailsEmpty(); + const shouldShowSkeleton = - (isLinkingToMessage && !isLinkedMessagePageReady) || (!isLinkingToMessage && !isInitialPageReady) || isLoadingReportOnyx || !isCurrentReportLoadedFromOnyx || isLoading; + (isLinkingToMessage && !isLinkedMessagePageReady) || + (!isLinkingToMessage && !isInitialPageReady) || + isEmptyObject(reportOnyx) || + isLoadingReportOnyx || + !isCurrentReportLoadedFromOnyx || + isLoading; // eslint-disable-next-line rulesdir/no-negated-variables const shouldShowNotFoundLinkedAction = diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 98b62616414..db491060a76 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -188,7 +188,7 @@ function ReportActionItem({ }); const theme = useTheme(); const styles = useThemeStyles(); - const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID || -1}`); const StyleUtils = useStyleUtils(); const personalDetails = usePersonalDetails() || CONST.EMPTY_OBJECT; const [isContextMenuActive, setIsContextMenuActive] = useState(() => ReportActionContextMenu.isActiveReportAction(action.reportActionID));