diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index acf4d7ed1399..7f313b1e70e8 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -174,6 +174,7 @@ function ReportActionsList({ const isReportArchived = useReportIsArchived(report?.reportID); const [isScrollToBottomEnabled, setIsScrollToBottomEnabled] = useState(false); + const [shouldScrollToEndAfterLayout, setShouldScrollToEndAfterLayout] = useState(false); const [actionIdToHighlight, setActionIdToHighlight] = useState(''); useEffect(() => { @@ -388,9 +389,19 @@ function ReportActionsList({ if (linkedReportActionID) { return; } + + const shouldScrollToEnd = (isExpenseReport(report) || isTransactionThread(parentReportAction)) && isSearchTopmostFullScreenRoute(); + + if (shouldScrollToEnd) { + setShouldScrollToEndAfterLayout(true); + } + InteractionManager.runAfterInteractions(() => { setIsFloatingMessageCounterVisible(false); - reportScrollManager.scrollToBottom(); + + if (!shouldScrollToEnd) { + reportScrollManager.scrollToBottom(); + } }); // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps }, []); @@ -678,8 +689,12 @@ function ReportActionsList({ reportScrollManager.scrollToBottom(); setIsScrollToBottomEnabled(false); } + if (shouldScrollToEndAfterLayout) { + reportScrollManager.scrollToEnd(); + setShouldScrollToEndAfterLayout(false); + } }, - [isScrollToBottomEnabled, onLayout, reportScrollManager], + [isScrollToBottomEnabled, onLayout, reportScrollManager, shouldScrollToEndAfterLayout], ); const retryLoadNewerChatsError = useCallback(() => {