diff --git a/src/hooks/useReportScrollManager/index.native.ts b/src/hooks/useReportScrollManager/index.native.ts index 20416dd96bf7..6666a4ebd0f2 100644 --- a/src/hooks/useReportScrollManager/index.native.ts +++ b/src/hooks/useReportScrollManager/index.native.ts @@ -7,17 +7,13 @@ function useReportScrollManager(): ReportScrollManagerData { /** * Scroll to the provided index. - * @param viewPosition (optional) - `0`: top, `0.5`: center, `1`: bottom */ - // We're defaulting isEditing to false in order to match the - // number of arguments that index.ts version has. - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const scrollToIndex = (index: number, isEditing = false, viewPosition?: number) => { + const scrollToIndex = (index: number) => { if (!flatListRef?.current) { return; } - flatListRef.current.scrollToIndex({index, viewPosition}); + flatListRef.current.scrollToIndex({index}); }; /** diff --git a/src/hooks/useReportScrollManager/index.ts b/src/hooks/useReportScrollManager/index.ts index 11e92991c28e..c60ba771917e 100644 --- a/src/hooks/useReportScrollManager/index.ts +++ b/src/hooks/useReportScrollManager/index.ts @@ -6,17 +6,14 @@ function useReportScrollManager(): ReportScrollManagerData { const {flatListRef} = useContext(ActionListContext); /** - * Scroll to the provided index. - * On non-native implementations we do not want to scroll when we are scrolling because - * we are editing a comment. - * @param viewPosition (optional) - `0`: top, `0.5`: center, `1`: bottom + * Scroll to the provided index. On non-native implementations we do not want to scroll when we are scrolling because */ - const scrollToIndex = (index: number, isEditing?: boolean, viewPosition?: number) => { + const scrollToIndex = (index: number, isEditing?: boolean) => { if (!flatListRef?.current || isEditing) { return; } - flatListRef.current.scrollToIndex({index, animated: true, viewPosition}); + flatListRef.current.scrollToIndex({index, animated: true}); }; /** diff --git a/src/hooks/useReportScrollManager/types.ts b/src/hooks/useReportScrollManager/types.ts index 881114498221..5182f7269a9c 100644 --- a/src/hooks/useReportScrollManager/types.ts +++ b/src/hooks/useReportScrollManager/types.ts @@ -2,7 +2,7 @@ import type {FlatListRefType} from '@pages/home/ReportScreenContext'; type ReportScrollManagerData = { ref: FlatListRefType; - scrollToIndex: (index: number, isEditing?: boolean, viewPosition?: number) => void; + scrollToIndex: (index: number, isEditing?: boolean) => void; scrollToBottom: () => void; }; diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index 6eb4da41468e..24881c7a5825 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -507,31 +507,6 @@ function ReportActionsList({ calculateUnreadMarker(); }, [calculateUnreadMarker, report.lastReadTime, messageManuallyMarkedUnread]); - useEffect(() => { - const scrollToFirstUnreadMessage = () => { - if (!currentUnreadMarker) { - return; - } - - const unreadMessageIndex = sortedVisibleReportActions.findIndex((action) => action.reportActionID === currentUnreadMarker); - - // Checking that we have a valid unread message index and the user scroll - // offset is less than the threshold since we don't want to auto-scroll when - // the report is already open and New Messages marker is shown as user might be reading. - if (unreadMessageIndex !== -1 && scrollingVerticalOffset.current < VERTICAL_OFFSET_THRESHOLD) { - // We're passing viewPosition: 1 to scroll to the top of the - // unread message (marker) since we're using an inverted FlatList. - reportScrollManager?.scrollToIndex(unreadMessageIndex, false, 1); - } - }; - - // Call the scroll function after a small delay to ensure all items - // have been measured and the list is ready to be scrolled. - InteractionManager.runAfterInteractions(scrollToFirstUnreadMessage); - // We only want to run this effect once, when we're navigating to a report with unread messages. - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [sortedVisibleReportActions]); - useEffect(() => { if (!userActiveSince.current || report.reportID !== prevReportID) { return;