From 3d27150c5234e68c3a31bc1f21f17ec99c35043a Mon Sep 17 00:00:00 2001 From: Vivek Kumar Date: Mon, 30 May 2022 00:36:21 +0530 Subject: [PATCH] added check to make sure workspace chat report belongs to user --- src/libs/actions/Welcome.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Welcome.js b/src/libs/actions/Welcome.js index 375d89adff7f5..b5f25a6036443 100644 --- a/src/libs/actions/Welcome.js +++ b/src/libs/actions/Welcome.js @@ -17,6 +17,7 @@ let isReadyPromise = new Promise((resolve) => { let isFirstTimeNewExpensifyUser; let isLoadingReportData = true; let isLoadingPolicyData = true; +let email = ''; /** * Check that a few requests have completed so that the welcome action can proceed: @@ -85,6 +86,17 @@ Onyx.connect({ }, }); +Onyx.connect({ + key: ONYXKEYS.SESSION, + callback: (val, key) => { + if (!val || !key) { + return; + } + + email = val.email; + }, +}); + /** * Shows a welcome action on first login * @@ -102,7 +114,7 @@ function show({routes, showCreateMenu}) { NameValuePair.set(CONST.NVP.IS_FIRST_TIME_NEW_EXPENSIFY_USER, false, ONYXKEYS.NVP_IS_FIRST_TIME_NEW_EXPENSIFY_USER); // We want to display the Workspace chat first since that means a user is already in a Workspace and doesn't need to create another one - const workspaceChatReport = _.find(allReports, report => ReportUtils.isPolicyExpenseChat(report)); + const workspaceChatReport = _.find(allReports, report => ReportUtils.isPolicyExpenseChat(report) && report.ownerEmail === email); if (workspaceChatReport) { Navigation.navigate(ROUTES.getReportRoute(workspaceChatReport.reportID)); return;