From 80ea5ca2588c0ad6211dacf2785942109707453a Mon Sep 17 00:00:00 2001 From: mkhutornyi Date: Thu, 16 Nov 2023 17:48:51 +0100 Subject: [PATCH 1/2] fix crash when login via email link as a new user --- src/libs/ReportActionsUtils.ts | 3 +++ 1 file changed, 3 insertions(+) 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 : ''; } From c671ae2d78a95a43ca3336b01c549f06d071ee02 Mon Sep 17 00:00:00 2001 From: mkhutornyi Date: Thu, 16 Nov 2023 17:59:04 +0100 Subject: [PATCH 2/2] fix potential crash --- src/pages/home/report/ReportActionsView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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