diff --git a/src/libs/PaginationUtils.ts b/src/libs/PaginationUtils.ts index fe75b6fb9927..a08868f5dcc1 100644 --- a/src/libs/PaginationUtils.ts +++ b/src/libs/PaginationUtils.ts @@ -124,7 +124,7 @@ function mergeAndSortContinuousPages(sortedItems: TResource[], pages: const result = [sortedPages[0]]; for (let i = 1; i < sortedPages.length; i++) { const page = sortedPages[i]; - const prevPage = sortedPages[i - 1]; + const prevPage = result[result.length - 1]; // Current page is inside the previous page, skip if (page.lastIndex <= prevPage.lastIndex && page.lastID !== CONST.PAGINATION_END_ID) { diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index 28ffbe025e41..17477ba65665 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -99,6 +99,7 @@ function ReportActionsView({ const reactionListRef = useContext(ReactionListContext); const route = useRoute>(); const reportActionID = route?.params?.reportActionID; + const prevReportActionID = usePrevious(reportActionID); const didLayout = useRef(false); const didLoadOlderChats = useRef(false); const didLoadNewerChats = useRef(false); @@ -141,7 +142,7 @@ function ReportActionsView({ // Change the list ID only for comment linking to get the positioning right const listID = useMemo(() => { - if (!reportActionID) { + if (!reportActionID && !prevReportActionID) { // Keep the old list ID since we're not in the Comment Linking flow return listOldID; }