From f6c11e0da65278eb57b0e4c1412da7a1e0606ef9 Mon Sep 17 00:00:00 2001 From: Vit Horacek <36083550+mountiny@users.noreply.github.com> Date: Mon, 2 Oct 2023 12:47:01 +0100 Subject: [PATCH] Merge pull request #28584 from margelo/osp/fix-not-found-page [CP Staging] Fixes not found page not being shown properly when not having access to report (cherry picked from commit fac61c8abb5837123e2fe6956c5dbb233254109c) --- src/pages/home/ReportScreen.js | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index c30a8c7ed4a8..635be1fc77c5 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, @@ -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 = ( { setIsBannerVisible(false); @@ -364,17 +354,8 @@ function ReportScreen({ // eslint-disable-next-line rulesdir/no-negated-variables const shouldShowNotFoundPage = useMemo( - () => - (!firstRenderRef.current && - !_.isEmpty(report) && - !isDefaultReport && - !report.reportID && - !isOptimisticDelete && - !report.isLoadingReportActions && - !isLoading && - !userLeavingStatus) || - shouldHideReport, - [report, isLoading, shouldHideReport, isDefaultReport, isOptimisticDelete, userLeavingStatus], + () => (!firstRenderRef.current && !report.reportID && !isOptimisticDelete && !reportMetadata.isLoadingReportActions && !isLoading && !userLeavingStatus) || shouldHideReport, + [report, reportMetadata, isLoading, shouldHideReport, isOptimisticDelete, userLeavingStatus], ); return ( @@ -486,7 +467,7 @@ export default compose( reportMetadata: { key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_METADATA}${getReportID(route)}`, initialValue: { - isLoadingReportActions: false, + isLoadingReportActions: true, isLoadingMoreReportActions: false, }, },