diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 662e92658e9d..6491245469a1 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -171,6 +171,7 @@ 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 @@ -183,8 +184,6 @@ 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) { @@ -193,7 +192,7 @@ function ReportScreen({ Log.info(`[ReportScreen] no reportID found in params, setting it to lastAccessedReportID: ${lastAccessedReportID}`); navigation.setParams({reportID: lastAccessedReportID}); - }, [activeWorkspaceID, canUseDefaultRooms, navigation, route]); + }, [lastAccessedReportID, activeWorkspaceID, canUseDefaultRooms, navigation, route]); /** * Create a lightweight Report so as to keep the re-rendering as light as possible by