diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index c9dcf70a248c..5b30f3ea8c57 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -111,7 +111,7 @@ function ReportActionsView({ const {shouldUseNarrowLayout} = useResponsiveLayout(); const isFocused = useIsFocused(); - const [isNavigatingToLinkedMessage, setNavigatingToLinkedMessage] = useState(!!reportActionID); + const [isNavigatingToLinkedMessage, setNavigatingToLinkedMessage] = useState(false); const prevShouldUseNarrowLayoutRef = useRef(shouldUseNarrowLayout); const reportID = report.reportID; const isReportFullyVisible = useMemo((): boolean => getIsReportFullyVisible(isFocused), [isFocused]); @@ -279,16 +279,16 @@ function ReportActionsView({ useEffect(() => { let timerID: NodeJS.Timeout; - if (isTheFirstReportActionIsLinked) { + if (!isTheFirstReportActionIsLinked && reportActionID) { setNavigatingToLinkedMessage(true); - } else { // After navigating to the linked reportAction, apply this to correctly set // `autoscrollToTopThreshold` prop when linking to a specific reportAction. - // eslint-disable-next-line @typescript-eslint/no-deprecated InteractionManager.runAfterInteractions(() => { // Using a short delay to ensure the view is updated after interactions timerID = setTimeout(() => setNavigatingToLinkedMessage(false), 10); }); + } else { + setNavigatingToLinkedMessage(false); } return () => { @@ -297,7 +297,7 @@ function ReportActionsView({ } clearTimeout(timerID); }; - }, [isTheFirstReportActionIsLinked]); + }, [isTheFirstReportActionIsLinked, reportActionID]); // Show skeleton while loading initial report actions when data is incomplete/missing and online const shouldShowSkeletonForInitialLoad = isLoadingInitialReportActions && (isReportDataIncomplete || isMissingReportActions) && !isOffline;