diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index c03858cb15f3..4a59e90380b1 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -3382,7 +3382,16 @@ function shouldReportShowSubscript(report) { * @returns {Boolean} */ function isReportDataReady() { - return !_.isEmpty(allReports) && _.some(_.keys(allReports), (key) => allReports[key].reportID); + return !_.isEmpty(allReports) && _.some(_.keys(allReports), (key) => allReports[key] && allReports[key].reportID); +} + +/** + * Return true if reportID from path is valid + * @param {String} reportIDFromPath + * @returns {Boolean} + */ +function isValidReportIDFromPath(reportIDFromPath) { + return typeof reportIDFromPath === 'string' && !['', 'null', '0'].includes(reportIDFromPath); } /** @@ -3764,6 +3773,7 @@ export { isChildReport, shouldReportShowSubscript, isReportDataReady, + isValidReportIDFromPath, isSettled, isAllowedToComment, getBankAccountRoute, diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 635be1fc77c5..7a979ae18783 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -230,7 +230,7 @@ function ReportScreen({ // Report ID will be empty when the reports collection is empty. // This could happen when we are loading the collection for the first time after logging in. - if (!reportIDFromPath) { + if (!ReportUtils.isValidReportIDFromPath(reportIDFromPath)) { return; }