-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[NO QA] Migrate Expensify guide & employee emails checks #20474
Changes from all commits
8a480fc
1a5b372
b8f7302
6d4340c
b376e23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -355,22 +355,35 @@ function getBankAccountRoute(report) { | |
} | ||
|
||
/** | ||
* Returns true if there are any guides accounts (team.expensify.com) in emails | ||
* @param {Array} emails | ||
* Only returns true if this is our main 1:1 DM report with Concierge | ||
* | ||
* @param {Object} report | ||
* @returns {Boolean} | ||
*/ | ||
function hasExpensifyGuidesEmails(emails) { | ||
return _.some(emails, (email) => Str.extractEmailDomain(email) === CONST.EMAIL.GUIDES_DOMAIN); | ||
function isConciergeChatReport(report) { | ||
return lodashGet(report, 'participantAccountIDs', []).length === 1 && Number(report.participantAccountIDs[0]) === CONST.ACCOUNT_ID.CONCIERGE; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to make sure that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah it's fine actually. It's already wrapped with Number() in CONST.js There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True, I did set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All good |
||
} | ||
|
||
/** | ||
* Only returns true if this is our main 1:1 DM report with Concierge | ||
* Returns true if there are any Expensify accounts (i.e. with domain 'expensify.com') in the set of accountIDs | ||
* by cross-referencing the accountIDs with personalDetails. | ||
* | ||
* @param {Object} report | ||
* @param {Array<Number>} accountIDs | ||
* @return {Boolean} | ||
*/ | ||
function hasExpensifyEmails(accountIDs) { | ||
return _.some(accountIDs, (accountID) => Str.extractEmailDomain(lodashGet(allPersonalDetails, [accountID, 'login'], '')) === CONST.EXPENSIFY_PARTNER_NAME); | ||
} | ||
|
||
/** | ||
* Returns true if there are any guides accounts (team.expensify.com) in a list of accountIDs | ||
* by cross-referencing the accountIDs with personalDetails since guides that are participants | ||
* of the user's chats should have their personal details in Onyx. | ||
* @param {Array<Number>} accountIDs | ||
* @returns {Boolean} | ||
*/ | ||
function isConciergeChatReport(report) { | ||
return lodashGet(report, 'participantAccountIDs', []).length === 1 && Number(report.participantAccountIDs[0]) === CONST.ACCOUNT_ID.CONCIERGE; | ||
function hasExpensifyGuidesEmails(accountIDs) { | ||
return _.some(accountIDs, (accountID) => Str.extractEmailDomain(lodashGet(allPersonalDetails, [accountID, 'login'], '')) === CONST.EMAIL.GUIDES_DOMAIN); | ||
} | ||
|
||
/** | ||
|
@@ -400,11 +413,9 @@ function findLastAccessedReport(reports, ignoreDomainRooms, policies, isFirstTim | |
// We allow public announce rooms, admins, and announce rooms through since we bypass the default rooms beta for them. | ||
// Check where ReportUtils.findLastAccessedReport is called in MainDrawerNavigator.js for more context. | ||
// Domain rooms are now the only type of default room that are on the defaultRooms beta. | ||
// TODO: migrate to report.participantAccountIDs later - not sure how we'll determine if a list of account IDs | ||
// includes an expensify guide account ID :O | ||
sortedReports = _.filter( | ||
sortedReports, | ||
(report) => !isDomainRoom(report) || getPolicyType(report, policies) === CONST.POLICY.TYPE.FREE || hasExpensifyGuidesEmails(lodashGet(report, ['participants'], [])), | ||
(report) => !isDomainRoom(report) || getPolicyType(report, policies) === CONST.POLICY.TYPE.FREE || hasExpensifyGuidesEmails(lodashGet(report, ['participantAccountIDs'], [])), | ||
); | ||
} | ||
|
||
|
@@ -630,16 +641,6 @@ function hasAutomatedExpensifyAccountIDs(accountIDs) { | |
return _.intersection(accountIDs, CONST.EXPENSIFY_ACCOUNT_IDS).length > 0; | ||
} | ||
|
||
/** | ||
* Returns true if there are any Expensify accounts (i.e. with domain 'expensify.com') in the set of emails. | ||
* | ||
* @param {Array<String>} emails | ||
* @return {Boolean} | ||
*/ | ||
function hasExpensifyEmails(emails) { | ||
return _.some(emails, (email) => Str.extractEmailDomain(email) === CONST.EXPENSIFY_PARTNER_NAME); | ||
} | ||
|
||
/** | ||
* Whether the time row should be shown for a report. | ||
* @param {Array<Object>} personalDetails | ||
|
@@ -1832,14 +1833,12 @@ function canSeeDefaultRoom(report, policies, betas) { | |
} | ||
|
||
// Include domain rooms with Partner Managers (Expensify accounts) in them for accounts that are on a domain with an Approved Accountant | ||
// TODO: figure out how we can determine accountIDs of "expensify emails" | ||
if (isDomainRoom(report) && doesDomainHaveApprovedAccountant && hasExpensifyEmails(lodashGet(report, ['participants'], []))) { | ||
if (isDomainRoom(report) && doesDomainHaveApprovedAccountant && hasExpensifyEmails(lodashGet(report, ['participantAccountIDs'], []))) { | ||
return true; | ||
} | ||
|
||
// If the room has an assigned guide, it can be seen. | ||
// TODO: figure out how we can determine accountIDs of "expensify emails" | ||
if (hasExpensifyGuidesEmails(lodashGet(report, ['participants'], []))) { | ||
if (hasExpensifyGuidesEmails(lodashGet(report, ['participantAccountIDs'], []))) { | ||
return true; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just moved this closer to
hasExpensifyEmails
which is a very similar function