From 59174e2485f046826b552a219c121f8ec8485ff4 Mon Sep 17 00:00:00 2001 From: BrtqKr Date: Tue, 16 Jul 2024 17:40:36 +0200 Subject: [PATCH] move lastAccessedReportID calculation back to the useEffect --- src/pages/home/ReportScreen.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index d3ca56b95a71..9d32419b1c4a 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -158,7 +158,6 @@ function ReportScreen({ const isLoadingReportOnyx = isLoadingOnyxValue(reportResult); const permissions = useDeepCompareRef(reportOnyx?.permissions); - const lastAccessedReportID = ReportUtils.findLastAccessedReport(!canUseDefaultRooms, !!route.params.openOnAdminRoom, activeWorkspaceID)?.reportID; useEffect(() => { // Don't update if there is a reportID in the params already @@ -171,6 +170,8 @@ function ReportScreen({ return; } + const lastAccessedReportID = ReportUtils.findLastAccessedReport(!canUseDefaultRooms, !!route.params.openOnAdminRoom, activeWorkspaceID)?.reportID; + // It's possible that reports aren't fully loaded yet // in that case the reportID is undefined if (!lastAccessedReportID) { @@ -179,7 +180,7 @@ function ReportScreen({ Log.info(`[ReportScreen] no reportID found in params, setting it to lastAccessedReportID: ${lastAccessedReportID}`); navigation.setParams({reportID: lastAccessedReportID}); - }, [lastAccessedReportID, activeWorkspaceID, canUseDefaultRooms, navigation, route]); + }, [activeWorkspaceID, canUseDefaultRooms, navigation, route, finishedLoadingApp]); /** * Create a lightweight Report so as to keep the re-rendering as light as possible by