Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added check to make sure workspace chat report belongs to user #9213

Merged
merged 1 commit into from
Jun 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/libs/actions/Welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
*
Expand All @@ -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;
Expand Down