From 6c94b285c402c0369b187dd7073102b60f957a93 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Fri, 13 Aug 2021 20:58:59 +0530 Subject: [PATCH 01/10] fix(hide-automated-acc-trans): Updated OptionListUtils to add flags for filters --- src/libs/OptionsListUtils.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 718282357cc3..ceb674c7c8e3 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -293,6 +293,8 @@ function getOptions(reports, personalDetails, draftComments, activeReportID, { selectedOptions = [], maxRecentReportsToShow = 0, excludeConcierge = false, + excludeChronos = false, + excludeReceipts = false, excludeDefaultRooms = false, includeMultipleParticipantReports = false, includePersonalDetails = false, @@ -384,6 +386,14 @@ function getOptions(reports, personalDetails, draftComments, activeReportID, { loginOptionsToExclude.push({login: CONST.EMAIL.CONCIERGE}); } + if (excludeChronos) { + loginOptionsToExclude.push({login: CONST.EMAIL.CHRONOS}); + } + + if (excludeReceipts) { + loginOptionsToExclude.push({login: CONST.EMAIL.RECEIPTS}); + } + if (includeRecentReports) { for (let i = 0; i < allReportOptions.length; i++) { // Stop adding options to the recentReports array when we reach the maxRecentReportsToShow value @@ -527,7 +537,10 @@ function getSearchOptions( * @param {Object} reports * @param {Object} personalDetails * @param {String} searchValue - * @param {Boolean} excludeConcierge + * @param {Object} excludedOptions + * @param {Boolean} parameters.excludeConcierge + * @param {Boolean} parameters.excludeChronos + * @param {Boolean} parameters.excludeReceipts * @param {Array} betas * @returns {Object} */ @@ -535,7 +548,11 @@ function getNewChatOptions( reports, personalDetails, searchValue = '', - excludeConcierge, + { + excludeConcierge = false, + excludeChronos = false, + excludeReceipts = true, + } = {}, betas, ) { return getOptions(reports, personalDetails, {}, 0, { @@ -546,6 +563,8 @@ function getNewChatOptions( includeRecentReports: true, maxRecentReportsToShow: 5, excludeConcierge, + excludeChronos, + excludeReceipts, }); } From 414c4b492c38d3de5a107b3205384a75d25c6988 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Fri, 13 Aug 2021 20:59:37 +0530 Subject: [PATCH 02/10] fix(hide-automated-acc-trans): Hide chronos and receipts from Request money screen --- .../IOUParticipantsPage/IOUParticipantsRequest.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js index 6b3ee1b552bd..e28dff963e34 100755 --- a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js +++ b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js @@ -56,7 +56,11 @@ class IOUParticipantsRequest extends Component { props.reports, props.personalDetails, '', - true, + { + excludeConcierge: true, + excludeChronos: true, + excludeReceipts: true, + }, props.betas, ); @@ -128,7 +132,11 @@ class IOUParticipantsRequest extends Component { this.props.reports, this.props.personalDetails, searchValue, - true, + { + excludeConcierge: true, + excludeChronos: true, + excludeReceipts: true, + }, this.props.betas, ); this.setState({ From 771a3c948817c91736a2eb3c80c6f5c741647b0b Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Fri, 13 Aug 2021 21:00:03 +0530 Subject: [PATCH 03/10] fix(hide-automated-acc-trans): Added default allowed for receipts and chronos for chats --- src/pages/NewChatPage.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/NewChatPage.js b/src/pages/NewChatPage.js index 96b2153541f3..00075f1d5d0f 100755 --- a/src/pages/NewChatPage.js +++ b/src/pages/NewChatPage.js @@ -65,7 +65,11 @@ class NewChatPage extends Component { props.reports, props.personalDetails, '', - false, + { + excludeConcierge: false, + excludeChronos: false, + excludeReceipts: true, + }, props.betas, ); From 34644cc62f9407bf41112c85ea8a6c1486fb92fb Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Fri, 13 Aug 2021 21:00:33 +0530 Subject: [PATCH 04/10] fix(hide-automated-acc-trans): Added receipts email to const --- src/CONST.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CONST.js b/src/CONST.js index 7e930f9bb99b..481f6a6b7721 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -260,6 +260,7 @@ const CONST = { EMAIL: { CHRONOS: 'chronos@expensify.com', CONCIERGE: 'concierge@expensify.com', + RECEIPTS: 'receipts@expensify.com', }, ENVIRONMENT: { From 4afd1609f9f825d599f6feb29c6784796660795b Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Fri, 13 Aug 2021 22:28:23 +0530 Subject: [PATCH 05/10] fix(hide-automated-acc-trans): Hide chronos, receipts, etc. from getNewGroupChat --- src/libs/OptionsListUtils.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index ceb674c7c8e3..59285214e58b 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -538,9 +538,9 @@ function getSearchOptions( * @param {Object} personalDetails * @param {String} searchValue * @param {Object} excludedOptions - * @param {Boolean} parameters.excludeConcierge - * @param {Boolean} parameters.excludeChronos - * @param {Boolean} parameters.excludeReceipts + * @param {Boolean} excludedOptions.excludeConcierge + * @param {Boolean} excludedOptions.excludeChronos + * @param {Boolean} excludedOptions.excludeReceipts * @param {Array} betas * @returns {Object} */ @@ -607,7 +607,10 @@ function getIOUConfirmationOptionsFromParticipants( * @param {Object} personalDetails * @param {String} searchValue * @param {Array} selectedOptions - * @param {Boolean} excludeConcierge + * @param {Object} excludedOptions + * @param {Boolean} excludedOptions.excludeConcierge + * @param {Boolean} excludedOptions.excludeChronos + * @param {Boolean} excludedOptions.excludeReceipts * @param {Array} betas * @returns {Object} */ @@ -616,7 +619,11 @@ function getNewGroupOptions( personalDetails, searchValue = '', selectedOptions = [], - excludeConcierge, + { + excludeConcierge = false, + excludeChronos = false, + excludeReceipts = true, + } = {}, betas, ) { return getOptions(reports, personalDetails, {}, 0, { @@ -629,6 +636,8 @@ function getNewGroupOptions( includeMultipleParticipantReports: false, maxRecentReportsToShow: 5, excludeConcierge, + excludeChronos, + excludeReceipts, }); } From f8cc950158a408e76d983d1c3e2b6726569da960 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Fri, 13 Aug 2021 22:29:06 +0530 Subject: [PATCH 06/10] fix(hide-automated-acc-trans): Updated flags to hide automated accounts --- .../IOUParticipantsSplit.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js index 6b9c6e75dc46..34912d57d5bf 100755 --- a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js +++ b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js @@ -82,7 +82,11 @@ class IOUParticipantsSplit extends Component { props.personalDetails, '', props.participants, - true, + { + excludeConcierge: true, + excludeChronos: true, + excludeReceipts: true, + }, props.betas, ); @@ -183,7 +187,11 @@ class IOUParticipantsSplit extends Component { this.props.personalDetails, isOptionInList ? prevState.searchValue : '', newSelectedOptions, - true, + { + excludeConcierge: true, + excludeChronos: true, + excludeReceipts: true, + }, this.props.betas, ); return { @@ -220,7 +228,11 @@ class IOUParticipantsSplit extends Component { this.props.personalDetails, searchValue, [], - true, + { + excludeConcierge: true, + excludeChronos: true, + excludeReceipts: true, + }, this.props.betas, ); this.setState({ From 5a1d2941a5e9fef4abb076a4b7d39857dd5d7b5c Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Fri, 13 Aug 2021 22:39:57 +0530 Subject: [PATCH 07/10] fix(hide-automated-acc-trans): removed exluded emails from invite list --- src/libs/OptionsListUtils.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 59285214e58b..f19be56830fb 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -478,6 +478,7 @@ function getOptions(reports, personalDetails, draftComments, activeReportID, { && personalDetailsOptions.length === 0 && _.every(selectedOptions, option => option.login !== searchValue) && ((Str.isValidEmail(searchValue) && !Str.isDomainEmail(searchValue)) || Str.isValidPhone(searchValue)) + && (!_.find(loginOptionsToExclude, loginOptionToExclude => loginOptionToExclude.login === searchValue)) && (searchValue !== CONST.EMAIL.CHRONOS || Permissions.canUseChronos(betas)) ) { // If the phone number doesn't have an international code then let's prefix it with the From 709c98dcaaf1d7a69480a77d06dd8e4d9fc40779 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Fri, 13 Aug 2021 23:19:47 +0530 Subject: [PATCH 08/10] test(hide-automated-acc-trans): Modified tests for concierge --- tests/unit/OptionsListUtilsTest.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/unit/OptionsListUtilsTest.js b/tests/unit/OptionsListUtilsTest.js index 27ee71d6976a..7efc74b844fd 100644 --- a/tests/unit/OptionsListUtilsTest.js +++ b/tests/unit/OptionsListUtilsTest.js @@ -273,7 +273,9 @@ describe('OptionsListUtils', () => { ); // Test by excluding Concierge from the results - results = OptionsListUtils.getNewChatOptions(REPORTS_WITH_CONCIERGE, PERSONAL_DETAILS_WITH_CONCIERGE, '', true); + results = OptionsListUtils.getNewChatOptions( + REPORTS_WITH_CONCIERGE, PERSONAL_DETAILS_WITH_CONCIERGE, '', {excludeConcierge: true}, + ); // All the personalDetails should be returned minus the currently logged in user and Concierge expect(results.personalDetails.length).toBe(_.size(PERSONAL_DETAILS_WITH_CONCIERGE) - 2 - MAX_RECENT_REPORTS); @@ -402,7 +404,9 @@ describe('OptionsListUtils', () => { PERSONAL_DETAILS_WITH_CONCIERGE, '', [], - true, + { + excludeConcierge: true, + }, ); // We should expect all the personalDetails to show (minus the 5 that are already showing, From f99e35fdeafabc3383e626334b942c52ed6b6d3b Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Fri, 13 Aug 2021 23:24:25 +0530 Subject: [PATCH 09/10] test(hide-automated-acc-trans): Added exclusion tests for Chronos --- tests/unit/OptionsListUtilsTest.js | 61 ++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/tests/unit/OptionsListUtilsTest.js b/tests/unit/OptionsListUtilsTest.js index 7efc74b844fd..c893801a9111 100644 --- a/tests/unit/OptionsListUtilsTest.js +++ b/tests/unit/OptionsListUtilsTest.js @@ -162,6 +162,19 @@ describe('OptionsListUtils', () => { }, }; + const REPORTS_WITH_CHRONOS = { + ...REPORTS, + 10: { + lastVisitedTimestamp: 1610666739302, + lastMessageTimestamp: 1, + isPinned: false, + reportID: 10, + participants: ['chronos@expensify.com'], + reportName: 'Chronos', + unreadActionCount: 1, + }, + }; + const PERSONAL_DETAILS_WITH_CONCIERGE = { ...PERSONAL_DETAILS, @@ -171,6 +184,15 @@ describe('OptionsListUtils', () => { }, }; + const PERSONAL_DETAILS_WITH_CHRONOS = { + ...PERSONAL_DETAILS, + + 'chronos@expensify.com': { + displayName: 'Chronos', + login: 'chronos@expensify.com', + }, + }; + // Set the currently logged in user, report data, and personal details beforeAll(() => { Onyx.init({ @@ -284,6 +306,19 @@ describe('OptionsListUtils', () => { expect.objectContaining({login: 'concierge@expensify.com'}), ]), ); + + // Test by excluding Chronos from the results + results = OptionsListUtils.getNewChatOptions( + REPORTS_WITH_CHRONOS, PERSONAL_DETAILS_WITH_CHRONOS, '', {excludeChronos: true}, + ); + + // All the personalDetails should be returned minus the currently logged in user and Concierge + expect(results.personalDetails.length).toBe(_.size(PERSONAL_DETAILS_WITH_CHRONOS) - 2 - MAX_RECENT_REPORTS); + expect(results.personalDetails).not.toEqual( + expect.arrayContaining([ + expect.objectContaining({login: 'chronos@expensify.com'}), + ]), + ); }); it('getNewGroupOptions()', () => { @@ -422,6 +457,32 @@ describe('OptionsListUtils', () => { expect.objectContaining({login: 'concierge@expensify.com'}), ]), ); + + + // Test by excluding Chronos from the results + results = OptionsListUtils.getNewGroupOptions( + REPORTS_WITH_CHRONOS, + PERSONAL_DETAILS_WITH_CHRONOS, + '', + [], + { + excludeChronos: true, + }, + ); + + // We should expect all the personalDetails to show (minus the 5 that are already showing, + // the currently logged in user and Concierge) + expect(results.personalDetails.length).toBe(_.size(PERSONAL_DETAILS_WITH_CHRONOS) - 7); + expect(results.personalDetails).not.toEqual( + expect.arrayContaining([ + expect.objectContaining({login: 'chronos@expensify.com'}), + ]), + ); + expect(results.recentReports).not.toEqual( + expect.arrayContaining([ + expect.objectContaining({login: 'chronos@expensify.com'}), + ]), + ); }); it('getSidebarOptions() with default priority mode', () => { From d28b65f1d5caa7038e05a2fd1c3e58ef9efab8c9 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Fri, 13 Aug 2021 23:27:23 +0530 Subject: [PATCH 10/10] test(hide-automated-acc-trans): Added exclusion tests for Receipts --- tests/unit/OptionsListUtilsTest.js | 62 +++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/tests/unit/OptionsListUtilsTest.js b/tests/unit/OptionsListUtilsTest.js index c893801a9111..3a9b992050ad 100644 --- a/tests/unit/OptionsListUtilsTest.js +++ b/tests/unit/OptionsListUtilsTest.js @@ -164,7 +164,7 @@ describe('OptionsListUtils', () => { const REPORTS_WITH_CHRONOS = { ...REPORTS, - 10: { + 11: { lastVisitedTimestamp: 1610666739302, lastMessageTimestamp: 1, isPinned: false, @@ -175,6 +175,19 @@ describe('OptionsListUtils', () => { }, }; + const REPORTS_WITH_RECEIPTS = { + ...REPORTS, + 12: { + lastVisitedTimestamp: 1610666739302, + lastMessageTimestamp: 1, + isPinned: false, + reportID: 10, + participants: ['receipts@expensify.com'], + reportName: 'Receipts', + unreadActionCount: 1, + }, + }; + const PERSONAL_DETAILS_WITH_CONCIERGE = { ...PERSONAL_DETAILS, @@ -193,6 +206,15 @@ describe('OptionsListUtils', () => { }, }; + const PERSONAL_DETAILS_WITH_RECEIPTS = { + ...PERSONAL_DETAILS, + + 'receipts@expensify.com': { + displayName: 'Receipts', + login: 'receipts@expensify.com', + }, + }; + // Set the currently logged in user, report data, and personal details beforeAll(() => { Onyx.init({ @@ -319,6 +341,19 @@ describe('OptionsListUtils', () => { expect.objectContaining({login: 'chronos@expensify.com'}), ]), ); + + // Test by excluding Receipts from the results + results = OptionsListUtils.getNewChatOptions( + REPORTS_WITH_RECEIPTS, PERSONAL_DETAILS_WITH_RECEIPTS, '', {excludeReceipts: true}, + ); + + // All the personalDetails should be returned minus the currently logged in user and Concierge + expect(results.personalDetails.length).toBe(_.size(PERSONAL_DETAILS_WITH_RECEIPTS) - 2 - MAX_RECENT_REPORTS); + expect(results.personalDetails).not.toEqual( + expect.arrayContaining([ + expect.objectContaining({login: 'receipts@expensify.com'}), + ]), + ); }); it('getNewGroupOptions()', () => { @@ -483,6 +518,31 @@ describe('OptionsListUtils', () => { expect.objectContaining({login: 'chronos@expensify.com'}), ]), ); + + // Test by excluding Receipts from the results + results = OptionsListUtils.getNewGroupOptions( + REPORTS_WITH_RECEIPTS, + PERSONAL_DETAILS_WITH_RECEIPTS, + '', + [], + { + excludeReceipts: true, + }, + ); + + // We should expect all the personalDetails to show (minus the 5 that are already showing, + // the currently logged in user and Concierge) + expect(results.personalDetails.length).toBe(_.size(PERSONAL_DETAILS_WITH_RECEIPTS) - 7); + expect(results.personalDetails).not.toEqual( + expect.arrayContaining([ + expect.objectContaining({login: 'receipts@expensify.com'}), + ]), + ); + expect(results.recentReports).not.toEqual( + expect.arrayContaining([ + expect.objectContaining({login: 'receipts@expensify.com'}), + ]), + ); }); it('getSidebarOptions() with default priority mode', () => {