From a6996dab562e1f0689b8266190fe31d97b235864 Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Mon, 2 Oct 2023 09:40:06 +0200 Subject: [PATCH 1/5] Fixes not found page not being shown properly --- src/pages/home/ReportScreen.js | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index c30a8c7ed4a8..7505e00f833c 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -118,15 +118,6 @@ const defaultProps = { ...withCurrentReportIDDefaultProps, }; -/** - * - * Function to check weather the report available in props is default - * - * @param {Object} report - * @returns {Boolean} - */ -const checkDefaultReport = (report) => report === defaultProps.report; - /** * Get the currently viewed report ID as number * @@ -188,8 +179,6 @@ function ReportScreen({ const isTopMostReportId = currentReportID === getReportID(route); const didSubscribeToReportLeavingEvents = useRef(false); - const isDefaultReport = checkDefaultReport(report); - let headerView = ( - (!firstRenderRef.current && - !_.isEmpty(report) && - !isDefaultReport && - !report.reportID && - !isOptimisticDelete && - !report.isLoadingReportActions && - !isLoading && - !userLeavingStatus) || + (!firstRenderRef.current && !_.isEmpty(report) && !report.reportID && !isOptimisticDelete && !reportMetadata.isLoadingReportActions && !isLoading && !userLeavingStatus) || shouldHideReport, - [report, isLoading, shouldHideReport, isDefaultReport, isOptimisticDelete, userLeavingStatus], + [report, reportMetadata, isLoading, shouldHideReport, isOptimisticDelete, userLeavingStatus], ); return ( From 8b4e9ae2f5810692b44c7c00b12c60af1dbf62f0 Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Mon, 2 Oct 2023 10:32:28 +0200 Subject: [PATCH 2/5] Change initial value for ReportScreen metadata->isLoadingReportActions --- src/pages/home/ReportScreen.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 7505e00f833c..46604b435714 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -105,7 +105,7 @@ const defaultProps = { hasOutstandingIOU: false, }, reportMetadata: { - isLoadingReportActions: false, + isLoadingReportActions: true, isLoadingMoreReportActions: false, }, isComposerFullSize: false, @@ -468,7 +468,7 @@ export default compose( reportMetadata: { key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_METADATA}${getReportID(route)}`, initialValue: { - isLoadingReportActions: false, + isLoadingReportActions: true, isLoadingMoreReportActions: false, }, }, From a18d2fc4a8a441628c9f02bc04fb746056c1cc7a Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Mon, 2 Oct 2023 13:22:24 +0200 Subject: [PATCH 3/5] Update check for calling openReport --- src/pages/home/ReportScreen.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 46604b435714..87f3bbfd028b 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -237,9 +237,10 @@ function ReportScreen({ // It possible that we may not have the report object yet in Onyx yet e.g. we navigated to a URL for an accessible report that // is not stored locally yet. If report.reportID exists, then the report has been stored locally and nothing more needs to be done. // If it doesn't exist, then we fetch the report from the API. - if (report.reportID && report.reportID === getReportID(route)) { + if (report.reportID && report.reportID === getReportID(route) && !_.isEmpty(reportActions)) { return; } + Report.openReport(reportIDFromPath); }, [report.reportID, route]); @@ -353,11 +354,21 @@ function ReportScreen({ // eslint-disable-next-line rulesdir/no-negated-variables const shouldShowNotFoundPage = useMemo( - () => - (!firstRenderRef.current && !_.isEmpty(report) && !report.reportID && !isOptimisticDelete && !reportMetadata.isLoadingReportActions && !isLoading && !userLeavingStatus) || - shouldHideReport, + () => (!firstRenderRef.current && !report.reportID && !isOptimisticDelete && !reportMetadata.isLoadingReportActions && !isLoading && !userLeavingStatus) || shouldHideReport, [report, reportMetadata, isLoading, shouldHideReport, isOptimisticDelete, userLeavingStatus], ); + console.log('Report Screen render'); + + console.log(report); + + console.table({ + shouldShowNotFoundPage, + reportId: report.reportID, + isOptimisticDelete, + isLoadingReportActions: reportMetadata.isLoadingReportActions, + isLoading, + userLeavingStatus, + }); return ( From ee43f7eb7bfe90feece9520fce1c6af9e0d27885 Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Mon, 2 Oct 2023 13:27:31 +0200 Subject: [PATCH 4/5] Update src/pages/home/ReportScreen.js Co-authored-by: Fedi Rajhi --- src/pages/home/ReportScreen.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 87f3bbfd028b..2e3cf6073596 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -357,18 +357,6 @@ function ReportScreen({ () => (!firstRenderRef.current && !report.reportID && !isOptimisticDelete && !reportMetadata.isLoadingReportActions && !isLoading && !userLeavingStatus) || shouldHideReport, [report, reportMetadata, isLoading, shouldHideReport, isOptimisticDelete, userLeavingStatus], ); - console.log('Report Screen render'); - - console.log(report); - - console.table({ - shouldShowNotFoundPage, - reportId: report.reportID, - isOptimisticDelete, - isLoadingReportActions: reportMetadata.isLoadingReportActions, - isLoading, - userLeavingStatus, - }); return ( From e841dd014b8700ef7f424f46b163f5a31f433c98 Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Mon, 2 Oct 2023 13:27:40 +0200 Subject: [PATCH 5/5] Update src/pages/home/ReportScreen.js Co-authored-by: Fedi Rajhi --- src/pages/home/ReportScreen.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 2e3cf6073596..635be1fc77c5 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -237,12 +237,12 @@ function ReportScreen({ // It possible that we may not have the report object yet in Onyx yet e.g. we navigated to a URL for an accessible report that // is not stored locally yet. If report.reportID exists, then the report has been stored locally and nothing more needs to be done. // If it doesn't exist, then we fetch the report from the API. - if (report.reportID && report.reportID === getReportID(route) && !_.isEmpty(reportActions)) { + if (report.reportID && report.reportID === getReportID(route) && !isLoadingInitialReportActions) { return; } Report.openReport(reportIDFromPath); - }, [report.reportID, route]); + }, [report.reportID, route, isLoadingInitialReportActions]); const dismissBanner = useCallback(() => { setIsBannerVisible(false);