From ac7a0c5f3ca1269bfa76585bffa692a1fe5e678c Mon Sep 17 00:00:00 2001 From: Shawn Erquhart Date: Mon, 20 Nov 2023 20:12:46 -0500 Subject: [PATCH 1/3] fix: ensure composer not full size when onyx state missing --- src/libs/actions/Report.js | 3 +++ src/pages/home/ReportScreen.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 5d42ccaf9e74..e5023de9183d 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -2002,6 +2002,9 @@ function openReportFromDeepLink(url, isAuthenticated) { Session.waitForUserSignIn().then(() => { Navigation.waitForProtectedRoutes().then(() => { const route = ReportUtils.getRouteFromLink(url); + if (!route) { + return; + } if (route === ROUTES.CONCIERGE) { navigateToConciergeChat(true); return; diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 09d147b05f69..bf924e744c50 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -128,7 +128,7 @@ const defaultProps = { */ function getReportID(route) { // // The reportID is used inside a collection key and should not be empty, as an empty reportID will result in the entire collection being returned. - return String(lodashGet(route, 'params.reportID', null)); + return String(lodashGet(route, 'params.reportID') || 0); } function ReportScreen({ From 281a940cfa1fd0c4286d3f1cb95acadc4ec736fc Mon Sep 17 00:00:00 2001 From: Shawn Erquhart Date: Tue, 21 Nov 2023 09:12:43 -0500 Subject: [PATCH 2/3] drop deeplink handler early return for empty routes --- src/libs/actions/Report.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index e5023de9183d..5d42ccaf9e74 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -2002,9 +2002,6 @@ function openReportFromDeepLink(url, isAuthenticated) { Session.waitForUserSignIn().then(() => { Navigation.waitForProtectedRoutes().then(() => { const route = ReportUtils.getRouteFromLink(url); - if (!route) { - return; - } if (route === ROUTES.CONCIERGE) { navigateToConciergeChat(true); return; From ef759316908a5b2579dd7a78f1c66f53f0eddec1 Mon Sep 17 00:00:00 2001 From: Shawn Erquhart Date: Tue, 21 Nov 2023 11:52:37 -0500 Subject: [PATCH 3/3] improve getReportID() solution comment --- src/pages/home/ReportScreen.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index bf924e744c50..7b58e0172870 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -127,7 +127,11 @@ const defaultProps = { * @returns {String} */ function getReportID(route) { - // // The reportID is used inside a collection key and should not be empty, as an empty reportID will result in the entire collection being returned. + // The report ID is used in an onyx key. If it's an empty string, onyx will return + // a collection instead of an individual report. + // We can't use the default value functionality of `lodash.get()` because it only + // provides a default value on `undefined`, and will return an empty string. + // Placing the default value outside of `lodash.get()` is intentional. return String(lodashGet(route, 'params.reportID') || 0); }