diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 371b8dfec43d..4615cac245ea 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -470,6 +470,9 @@ function getLastClosedReportAction(reportActions: ReportActions | null): OnyxEnt * action is always the created action */ function getFirstVisibleReportActionID(sortedReportActions: ReportAction[], isOffline: boolean): string { + if (!Array.isArray(sortedReportActions)) { + return ''; + } const sortedFilterReportActions = sortedReportActions.filter((action) => !isDeletedAction(action) || (action?.childVisibleActionCount ?? 0) > 0 || isOffline); return sortedFilterReportActions.length > 1 ? sortedFilterReportActions[sortedFilterReportActions.length - 2].reportActionID : ''; } diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index 01ec967d76b1..b4d21de919bf 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -185,7 +185,7 @@ function ReportActionsView(props) { const oldestReportAction = _.last(props.reportActions); // Don't load more chats if we're already at the beginning of the chat history - if (oldestReportAction.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) { + if (!oldestReportAction || oldestReportAction.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) { return; } // Retrieve the next REPORT.ACTIONS.LIMIT sized page of comments