From a2621922f6431de9f0268e12a04972bc30ef0d65 Mon Sep 17 00:00:00 2001 From: Thanos30 Date: Tue, 1 Aug 2023 17:35:34 +0300 Subject: [PATCH 01/16] Task Share Destination Fixes --- src/libs/OptionsListUtils.js | 14 ++++++++--- .../TaskShareDestinationSelectorModal.js | 25 ++----------------- 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 826c5886f70d..f6e3d0c44fce 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -615,6 +615,7 @@ function getOptions( includeThreads = false, includeTasks = false, includeMoneyRequests = false, + disallowNewChats = false, }, ) { if (!isPersonalDetailsReady(personalDetails)) { @@ -796,7 +797,8 @@ function getOptions( ((Str.isValidEmail(searchValue) && !Str.isDomainEmail(searchValue) && !Str.endsWith(searchValue, CONST.SMS.DOMAIN)) || (parsedPhoneNumber.possible && Str.isValidPhone(LoginUtils.getPhoneNumberWithoutSpecialChars(parsedPhoneNumber.number.input)))) && !_.find(loginOptionsToExclude, (loginOptionToExclude) => loginOptionToExclude.login === addSMSDomainIfPhoneNumber(searchValue).toLowerCase()) && - (searchValue !== CONST.EMAIL.CHRONOS || Permissions.canUseChronos(betas)) + (searchValue !== CONST.EMAIL.CHRONOS || Permissions.canUseChronos(betas)) && + !disallowNewChats ) { // Generates an optimistic account ID for new users not yet saved in Onyx const optimisticAccountID = UserUtils.generateAccountID(searchValue); @@ -966,17 +968,21 @@ function getNewChatOptions(reports, personalDetails, betas = [], searchValue = ' * */ -function getShareDestinationOptions(reports, personalDetails, betas = [], searchValue = '', selectedOptions = [], excludeLogins = [], includeOwnedWorkspaceChats = true) { +function getShareDestinationOptions(reports, personalDetails, betas = [], searchValue = '', selectedOptions = [], excludeLogins = [], includeOwnedWorkspaceChats = true, disallowNewChats = true) { return getOptions(reports, personalDetails, { betas, searchInputValue: searchValue.trim(), selectedOptions, - maxRecentReportsToShow: 5, + maxRecentReportsToShow: 0, // Unlimited includeRecentReports: true, includeMultipleParticipantReports: true, - includePersonalDetails: true, + includePersonalDetails: false, + includeThreads: true, + includeMoneyRequests: true, + includeTasks: true, excludeLogins, includeOwnedWorkspaceChats, + disallowNewChats, }); } diff --git a/src/pages/tasks/TaskShareDestinationSelectorModal.js b/src/pages/tasks/TaskShareDestinationSelectorModal.js index 7a4250d8cbe9..b41937aa58b0 100644 --- a/src/pages/tasks/TaskShareDestinationSelectorModal.js +++ b/src/pages/tasks/TaskShareDestinationSelectorModal.js @@ -45,8 +45,6 @@ function TaskShareDestinationSelectorModal(props) { const [searchValue, setSearchValue] = useState(''); const [headerMessage, setHeaderMessage] = useState(''); const [filteredRecentReports, setFilteredRecentReports] = useState([]); - const [filteredPersonalDetails, setFilteredPersonalDetails] = useState([]); - const [filteredUserToInvite, setFilteredUserToInvite] = useState(null); const filteredReports = useMemo(() => { const reports = {}; @@ -59,7 +57,7 @@ function TaskShareDestinationSelectorModal(props) { return reports; }, [props.reports]); const updateOptions = useCallback(() => { - const {recentReports, personalDetails, userToInvite} = OptionsListUtils.getShareDestinationOptions( + const { recentReports } = OptionsListUtils.getShareDestinationOptions( filteredReports, props.personalDetails, props.betas, @@ -69,11 +67,9 @@ function TaskShareDestinationSelectorModal(props) { true, ); - setHeaderMessage(OptionsListUtils.getHeaderMessage(recentReports?.length + personalDetails?.length !== 0, Boolean(userToInvite), searchValue)); + setHeaderMessage(OptionsListUtils.getHeaderMessage(recentReports?.length !== 0, false, searchValue)); - setFilteredUserToInvite(userToInvite); setFilteredRecentReports(recentReports); - setFilteredPersonalDetails(personalDetails); }, [props, searchValue, filteredReports]); useEffect(() => { @@ -101,23 +97,6 @@ function TaskShareDestinationSelectorModal(props) { indexOffset += filteredRecentReports?.length; } - if (filteredPersonalDetails?.length > 0) { - sections.push({ - data: filteredPersonalDetails, - shouldShow: true, - indexOffset, - }); - indexOffset += filteredRecentReports?.length; - } - - if (filteredUserToInvite) { - sections.push({ - data: [filteredUserToInvite], - shouldShow: true, - indexOffset, - }); - } - return sections; }; From 8c98c9a67e7c4cabe6e9f7616f95e3e5fab0fdad Mon Sep 17 00:00:00 2001 From: Thanos30 Date: Tue, 1 Aug 2023 20:21:20 +0300 Subject: [PATCH 02/16] Apply options discussed in issue --- src/libs/OptionsListUtils.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index f6e3d0c44fce..c782405f014b 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -977,6 +977,9 @@ function getShareDestinationOptions(reports, personalDetails, betas = [], search includeRecentReports: true, includeMultipleParticipantReports: true, includePersonalDetails: false, + showChatPreviewLine: true, + sortByReportTypeInSearch: true, + forcePolicyNamePreview: true, includeThreads: true, includeMoneyRequests: true, includeTasks: true, From b670ed5535d439a8b79fd413b1c4f75f3067db5c Mon Sep 17 00:00:00 2001 From: Thanos30 Date: Tue, 1 Aug 2023 20:28:01 +0300 Subject: [PATCH 03/16] remove not needed parameter --- src/libs/OptionsListUtils.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index c782405f014b..d675c6fd05c5 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -978,7 +978,6 @@ function getShareDestinationOptions(reports, personalDetails, betas = [], search includeMultipleParticipantReports: true, includePersonalDetails: false, showChatPreviewLine: true, - sortByReportTypeInSearch: true, forcePolicyNamePreview: true, includeThreads: true, includeMoneyRequests: true, From c3591e5dc6435bcc6fd9f288c3435c4f9f4a2995 Mon Sep 17 00:00:00 2001 From: Thanos30 Date: Tue, 1 Aug 2023 21:36:47 +0300 Subject: [PATCH 04/16] Update test to match new functionality --- tests/unit/OptionsListUtilsTest.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/unit/OptionsListUtilsTest.js b/tests/unit/OptionsListUtilsTest.js index 76ac7990d133..bfafd7f99e19 100644 --- a/tests/unit/OptionsListUtilsTest.js +++ b/tests/unit/OptionsListUtilsTest.js @@ -570,9 +570,8 @@ describe('OptionsListUtils', () => { // When we pass an empty search value let results = OptionsListUtils.getShareDestinationOptions(REPORTS, PERSONAL_DETAILS, [], ''); - // Then we should expect 5 recent reports to show because we're grabbing DM chats and group chats - // because we've limited the number of recent reports to 5 - expect(results.recentReports.length).toBe(5); + // Then we should expect all the recent reports to show + expect(results.recentReports.length).toBe(_.size(REPORTS)); // When we pass a search value that doesn't match the group chat name results = OptionsListUtils.getShareDestinationOptions(REPORTS, PERSONAL_DETAILS, [], 'mutants'); @@ -590,8 +589,8 @@ describe('OptionsListUtils', () => { results = OptionsListUtils.getShareDestinationOptions(REPORTS_WITH_WORKSPACE_ROOMS, PERSONAL_DETAILS, [], ''); // Then we should expect the DMS, the group chats and the workspace room to show - // We should expect 5 recent reports to show because we've limited the number of recent reports to 5 - expect(results.recentReports.length).toBe(5); + // We should expect all the recent reports to show + expect(results.recentReports.length).toBe(_.size(REPORTS_WITH_WORKSPACE_ROOMS)); // When we search for a workspace room results = OptionsListUtils.getShareDestinationOptions(REPORTS_WITH_WORKSPACE_ROOMS, PERSONAL_DETAILS, [], 'Avengers Room'); From 603b30535d2f749676a97ce745e83cf44d0cd331 Mon Sep 17 00:00:00 2001 From: Thanos30 Date: Tue, 1 Aug 2023 21:48:09 +0300 Subject: [PATCH 05/16] prettify code and correct test to exclude archived rooms --- src/libs/OptionsListUtils.js | 11 ++++++++++- src/pages/tasks/TaskShareDestinationSelectorModal.js | 10 +--------- tests/unit/OptionsListUtilsTest.js | 4 ++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index d675c6fd05c5..3f908697b16f 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -968,7 +968,16 @@ function getNewChatOptions(reports, personalDetails, betas = [], searchValue = ' * */ -function getShareDestinationOptions(reports, personalDetails, betas = [], searchValue = '', selectedOptions = [], excludeLogins = [], includeOwnedWorkspaceChats = true, disallowNewChats = true) { +function getShareDestinationOptions( + reports, + personalDetails, + betas = [], + searchValue = '', + selectedOptions = [], + excludeLogins = [], + includeOwnedWorkspaceChats = true, + disallowNewChats = true, +) { return getOptions(reports, personalDetails, { betas, searchInputValue: searchValue.trim(), diff --git a/src/pages/tasks/TaskShareDestinationSelectorModal.js b/src/pages/tasks/TaskShareDestinationSelectorModal.js index b41937aa58b0..c9235551b6a7 100644 --- a/src/pages/tasks/TaskShareDestinationSelectorModal.js +++ b/src/pages/tasks/TaskShareDestinationSelectorModal.js @@ -57,15 +57,7 @@ function TaskShareDestinationSelectorModal(props) { return reports; }, [props.reports]); const updateOptions = useCallback(() => { - const { recentReports } = OptionsListUtils.getShareDestinationOptions( - filteredReports, - props.personalDetails, - props.betas, - searchValue.trim(), - [], - CONST.EXPENSIFY_EMAILS, - true, - ); + const {recentReports} = OptionsListUtils.getShareDestinationOptions(filteredReports, props.personalDetails, props.betas, searchValue.trim(), [], CONST.EXPENSIFY_EMAILS, true); setHeaderMessage(OptionsListUtils.getHeaderMessage(recentReports?.length !== 0, false, searchValue)); diff --git a/tests/unit/OptionsListUtilsTest.js b/tests/unit/OptionsListUtilsTest.js index bfafd7f99e19..9fa5f444189c 100644 --- a/tests/unit/OptionsListUtilsTest.js +++ b/tests/unit/OptionsListUtilsTest.js @@ -570,8 +570,8 @@ describe('OptionsListUtils', () => { // When we pass an empty search value let results = OptionsListUtils.getShareDestinationOptions(REPORTS, PERSONAL_DETAILS, [], ''); - // Then we should expect all the recent reports to show - expect(results.recentReports.length).toBe(_.size(REPORTS)); + // Then we should expect all the recent reports to show but exclude the archived rooms + expect(results.recentReports.length).toBe(_.size(REPORTS) - 1); // When we pass a search value that doesn't match the group chat name results = OptionsListUtils.getShareDestinationOptions(REPORTS, PERSONAL_DETAILS, [], 'mutants'); From 3dd530145861efc8c570cf9b07c3ab17f3c6d047 Mon Sep 17 00:00:00 2001 From: Thanos30 Date: Tue, 1 Aug 2023 21:52:34 +0300 Subject: [PATCH 06/16] add fic on workspace reports --- tests/unit/OptionsListUtilsTest.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/OptionsListUtilsTest.js b/tests/unit/OptionsListUtilsTest.js index 9fa5f444189c..1c176bdb1ce4 100644 --- a/tests/unit/OptionsListUtilsTest.js +++ b/tests/unit/OptionsListUtilsTest.js @@ -589,8 +589,8 @@ describe('OptionsListUtils', () => { results = OptionsListUtils.getShareDestinationOptions(REPORTS_WITH_WORKSPACE_ROOMS, PERSONAL_DETAILS, [], ''); // Then we should expect the DMS, the group chats and the workspace room to show - // We should expect all the recent reports to show - expect(results.recentReports.length).toBe(_.size(REPORTS_WITH_WORKSPACE_ROOMS)); + // We should expect all the recent reports to show, excluding the archived rooms + expect(results.recentReports.length).toBe(_.size(REPORTS_WITH_WORKSPACE_ROOMS) - 1); // When we search for a workspace room results = OptionsListUtils.getShareDestinationOptions(REPORTS_WITH_WORKSPACE_ROOMS, PERSONAL_DETAILS, [], 'Avengers Room'); From 157f56d085164bfe0a7b38b320a7bdd437f6ff4f Mon Sep 17 00:00:00 2001 From: Thanos30 Date: Thu, 3 Aug 2023 02:28:12 +0300 Subject: [PATCH 07/16] make name more obvious --- src/libs/OptionsListUtils.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 3f908697b16f..9c27fcaab8bb 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -615,7 +615,7 @@ function getOptions( includeThreads = false, includeTasks = false, includeMoneyRequests = false, - disallowNewChats = false, + excludeUnknownUsers = false, }, ) { if (!isPersonalDetailsReady(personalDetails)) { @@ -798,7 +798,7 @@ function getOptions( (parsedPhoneNumber.possible && Str.isValidPhone(LoginUtils.getPhoneNumberWithoutSpecialChars(parsedPhoneNumber.number.input)))) && !_.find(loginOptionsToExclude, (loginOptionToExclude) => loginOptionToExclude.login === addSMSDomainIfPhoneNumber(searchValue).toLowerCase()) && (searchValue !== CONST.EMAIL.CHRONOS || Permissions.canUseChronos(betas)) && - !disallowNewChats + !excludeUnknownUsers ) { // Generates an optimistic account ID for new users not yet saved in Onyx const optimisticAccountID = UserUtils.generateAccountID(searchValue); @@ -976,7 +976,7 @@ function getShareDestinationOptions( selectedOptions = [], excludeLogins = [], includeOwnedWorkspaceChats = true, - disallowNewChats = true, + excludeUnknownUsers = true, ) { return getOptions(reports, personalDetails, { betas, @@ -993,7 +993,7 @@ function getShareDestinationOptions( includeTasks: true, excludeLogins, includeOwnedWorkspaceChats, - disallowNewChats, + excludeUnknownUsers, }); } From e938e749ef032bf3dcb88b7f7ec15c1591906daf Mon Sep 17 00:00:00 2001 From: Thanos30 Date: Thu, 3 Aug 2023 03:31:55 +0300 Subject: [PATCH 08/16] exclude Archived Rooms --- src/pages/tasks/TaskShareDestinationSelectorModal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/tasks/TaskShareDestinationSelectorModal.js b/src/pages/tasks/TaskShareDestinationSelectorModal.js index c9235551b6a7..bd259c685876 100644 --- a/src/pages/tasks/TaskShareDestinationSelectorModal.js +++ b/src/pages/tasks/TaskShareDestinationSelectorModal.js @@ -49,7 +49,7 @@ function TaskShareDestinationSelectorModal(props) { const filteredReports = useMemo(() => { const reports = {}; _.keys(props.reports).forEach((reportKey) => { - if (!ReportUtils.isAllowedToComment(props.reports[reportKey])) { + if (!ReportUtils.isAllowedToComment(props.reports[reportKey]) || ReportUtils.isArchivedRoom(props.reports[reportKey])) { return; } reports[reportKey] = props.reports[reportKey]; From 1308dfdaa04a7385253a3e914f2df5a636bef250 Mon Sep 17 00:00:00 2001 From: Thanos30 Date: Thu, 3 Aug 2023 03:53:31 +0300 Subject: [PATCH 09/16] exclude expensify accounts --- src/pages/tasks/TaskShareDestinationSelectorModal.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pages/tasks/TaskShareDestinationSelectorModal.js b/src/pages/tasks/TaskShareDestinationSelectorModal.js index bd259c685876..59abef982c1e 100644 --- a/src/pages/tasks/TaskShareDestinationSelectorModal.js +++ b/src/pages/tasks/TaskShareDestinationSelectorModal.js @@ -1,6 +1,7 @@ /* eslint-disable es/no-optional-chaining */ import React, {useState, useEffect, useMemo, useCallback} from 'react'; import _ from 'underscore'; +import lodashGet from 'lodash/get'; import {View} from 'react-native'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; @@ -49,7 +50,13 @@ function TaskShareDestinationSelectorModal(props) { const filteredReports = useMemo(() => { const reports = {}; _.keys(props.reports).forEach((reportKey) => { - if (!ReportUtils.isAllowedToComment(props.reports[reportKey]) || ReportUtils.isArchivedRoom(props.reports[reportKey])) { + console.log('reportKey', props); + if ( + !ReportUtils.isAllowedToComment(props.reports[reportKey]) || + ReportUtils.isArchivedRoom(props.reports[reportKey]) || + (lodashGet(props.reports[reportKey], 'participantAccountIDs', []).length === 1 && + _.some(props.reports[reportKey].participantAccountIDs, (accountID) => _.contains(CONST.EXPENSIFY_ACCOUNT_IDS, accountID))) + ) { return; } reports[reportKey] = props.reports[reportKey]; From a21355ea41227300489ad06fdcdaaffcf52328c7 Mon Sep 17 00:00:00 2001 From: Thanos30 Date: Thu, 3 Aug 2023 04:20:13 +0300 Subject: [PATCH 10/16] Use common function to determine if we can share a task in a report --- src/libs/ReportUtils.js | 12 ++++++++++++ src/pages/home/report/ReportActionCompose.js | 4 ++-- src/pages/tasks/TaskShareDestinationSelectorModal.js | 6 ++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 91c35d4cd956..3df1816e905f 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -460,6 +460,17 @@ function isConciergeChatReport(report) { return lodashGet(report, 'participantAccountIDs', []).length === 1 && Number(report.participantAccountIDs[0]) === CONST.ACCOUNT_ID.CONCIERGE && !isChatThread(report); } +/** + * Returns true if we can share a task in this report + * @param {Object} report + * @returns {Boolean} + */ + +function canShareTaskInReport(report) { + const reportParticipants = _.without(lodashGet(report, 'participantAccountIDs', []), currentUserAccountID); + return (lodashGet(report, 'participantAccountIDs', []).length === 1 && _.some(reportParticipants, (accountID) => _.contains(CONST.EXPENSIFY_ACCOUNT_IDS, accountID))) +} + /** * 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. @@ -2834,6 +2845,7 @@ export { findLastAccessedReport, canEditReportAction, canFlagReportAction, + canShareTaskInReport, shouldShowFlagComment, canDeleteReportAction, canLeaveRoom, diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index 644a90216091..cd2a2d7a1d3f 100644 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -450,11 +450,11 @@ class ReportActionCompose extends React.Component { * @param {Array} reportParticipants * @returns {Boolean} */ - getTaskOption(reportParticipants) { + getTaskOption() { // We only prevent the task option from showing if it's a DM and the other user is an Expensify default email if ( !Permissions.canUseTasks(this.props.betas) || - (lodashGet(this.props.report, 'participantAccountIDs', []).length === 1 && _.some(reportParticipants, (accountID) => _.contains(CONST.EXPENSIFY_ACCOUNT_IDS, accountID))) + ReportUtils.canShareTaskInReport(this.props.report) ) { return []; } diff --git a/src/pages/tasks/TaskShareDestinationSelectorModal.js b/src/pages/tasks/TaskShareDestinationSelectorModal.js index 59abef982c1e..cc67ee8d47a7 100644 --- a/src/pages/tasks/TaskShareDestinationSelectorModal.js +++ b/src/pages/tasks/TaskShareDestinationSelectorModal.js @@ -1,11 +1,11 @@ /* eslint-disable es/no-optional-chaining */ import React, {useState, useEffect, useMemo, useCallback} from 'react'; import _ from 'underscore'; -import lodashGet from 'lodash/get'; import {View} from 'react-native'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import OptionsSelector from '../../components/OptionsSelector'; + import * as OptionsListUtils from '../../libs/OptionsListUtils'; import ONYXKEYS from '../../ONYXKEYS'; import styles from '../../styles/styles'; @@ -50,12 +50,10 @@ function TaskShareDestinationSelectorModal(props) { const filteredReports = useMemo(() => { const reports = {}; _.keys(props.reports).forEach((reportKey) => { - console.log('reportKey', props); if ( !ReportUtils.isAllowedToComment(props.reports[reportKey]) || ReportUtils.isArchivedRoom(props.reports[reportKey]) || - (lodashGet(props.reports[reportKey], 'participantAccountIDs', []).length === 1 && - _.some(props.reports[reportKey].participantAccountIDs, (accountID) => _.contains(CONST.EXPENSIFY_ACCOUNT_IDS, accountID))) + ReportUtils.canShareTaskInReport(props.reports[reportKey]) ) { return; } From c703f7df90418c2ac076620c7aa2d91c39f7e142 Mon Sep 17 00:00:00 2001 From: Thanos30 Date: Thu, 3 Aug 2023 04:21:47 +0300 Subject: [PATCH 11/16] prettify --- src/libs/ReportUtils.js | 2 +- src/pages/home/report/ReportActionCompose.js | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 3df1816e905f..91e68bf6da60 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -468,7 +468,7 @@ function isConciergeChatReport(report) { function canShareTaskInReport(report) { const reportParticipants = _.without(lodashGet(report, 'participantAccountIDs', []), currentUserAccountID); - return (lodashGet(report, 'participantAccountIDs', []).length === 1 && _.some(reportParticipants, (accountID) => _.contains(CONST.EXPENSIFY_ACCOUNT_IDS, accountID))) + return lodashGet(report, 'participantAccountIDs', []).length === 1 && _.some(reportParticipants, (accountID) => _.contains(CONST.EXPENSIFY_ACCOUNT_IDS, accountID)); } /** diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index cd2a2d7a1d3f..bc86c835c755 100644 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -452,10 +452,7 @@ class ReportActionCompose extends React.Component { */ getTaskOption() { // We only prevent the task option from showing if it's a DM and the other user is an Expensify default email - if ( - !Permissions.canUseTasks(this.props.betas) || - ReportUtils.canShareTaskInReport(this.props.report) - ) { + if (!Permissions.canUseTasks(this.props.betas) || ReportUtils.canShareTaskInReport(this.props.report)) { return []; } From 6bac6dc687097b2465bf53ed9d9766c05a07a15f Mon Sep 17 00:00:00 2001 From: Thanos30 Date: Thu, 3 Aug 2023 04:28:05 +0300 Subject: [PATCH 12/16] fix name accuracy --- src/libs/ReportUtils.js | 4 ++-- src/pages/home/report/ReportActionCompose.js | 2 +- src/pages/tasks/TaskShareDestinationSelectorModal.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 91e68bf6da60..784b7909e7f6 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -466,7 +466,7 @@ function isConciergeChatReport(report) { * @returns {Boolean} */ -function canShareTaskInReport(report) { +function isExpensifyChatReport(report) { const reportParticipants = _.without(lodashGet(report, 'participantAccountIDs', []), currentUserAccountID); return lodashGet(report, 'participantAccountIDs', []).length === 1 && _.some(reportParticipants, (accountID) => _.contains(CONST.EXPENSIFY_ACCOUNT_IDS, accountID)); } @@ -2845,7 +2845,6 @@ export { findLastAccessedReport, canEditReportAction, canFlagReportAction, - canShareTaskInReport, shouldShowFlagComment, canDeleteReportAction, canLeaveRoom, @@ -2860,6 +2859,7 @@ export { getPolicyName, getPolicyType, isArchivedRoom, + isExpensifyChatReport, isPolicyExpenseChatAdmin, isPolicyAdmin, isPublicRoom, diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index bc86c835c755..bf1220ed5c20 100644 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -452,7 +452,7 @@ class ReportActionCompose extends React.Component { */ getTaskOption() { // We only prevent the task option from showing if it's a DM and the other user is an Expensify default email - if (!Permissions.canUseTasks(this.props.betas) || ReportUtils.canShareTaskInReport(this.props.report)) { + if (!Permissions.canUseTasks(this.props.betas) || ReportUtils.isExpensifyChatReport(this.props.report)) { return []; } diff --git a/src/pages/tasks/TaskShareDestinationSelectorModal.js b/src/pages/tasks/TaskShareDestinationSelectorModal.js index cc67ee8d47a7..35cfff25132a 100644 --- a/src/pages/tasks/TaskShareDestinationSelectorModal.js +++ b/src/pages/tasks/TaskShareDestinationSelectorModal.js @@ -53,7 +53,7 @@ function TaskShareDestinationSelectorModal(props) { if ( !ReportUtils.isAllowedToComment(props.reports[reportKey]) || ReportUtils.isArchivedRoom(props.reports[reportKey]) || - ReportUtils.canShareTaskInReport(props.reports[reportKey]) + ReportUtils.isExpensifyChatReport(props.reports[reportKey]) ) { return; } From de39debb591180dc822f8a18765b5bc8e0f446fe Mon Sep 17 00:00:00 2001 From: Thanos30 Date: Thu, 3 Aug 2023 04:50:54 +0300 Subject: [PATCH 13/16] remove unneeded parameter --- src/pages/home/report/ReportActionCompose.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index bf1220ed5c20..0a7d6f612f5c 100644 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -1113,7 +1113,7 @@ class ReportActionCompose extends React.Component { anchorAlignment={{horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM}} menuItems={[ ...this.getMoneyRequestOptions(reportParticipants), - ...this.getTaskOption(reportParticipants), + ...this.getTaskOption(), { icon: Expensicons.Paperclip, text: this.props.translate('reportActionCompose.addAttachment'), From b9cc192e24da83cf932e20018994f0af52be05b9 Mon Sep 17 00:00:00 2001 From: Thanos30 Date: Thu, 3 Aug 2023 21:27:54 +0300 Subject: [PATCH 14/16] update function's docs and name --- src/libs/ReportUtils.js | 6 +++--- src/pages/home/report/ReportActionCompose.js | 2 +- src/pages/tasks/TaskShareDestinationSelectorModal.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 784b7909e7f6..9d08ca7d6b75 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -461,12 +461,12 @@ function isConciergeChatReport(report) { } /** - * Returns true if we can share a task in this report + * Returns true if this report has only one participant and it's an Expensify account. * @param {Object} report * @returns {Boolean} */ -function isExpensifyChatReport(report) { +function isExpensifyOnlyParticipantInReport(report) { const reportParticipants = _.without(lodashGet(report, 'participantAccountIDs', []), currentUserAccountID); return lodashGet(report, 'participantAccountIDs', []).length === 1 && _.some(reportParticipants, (accountID) => _.contains(CONST.EXPENSIFY_ACCOUNT_IDS, accountID)); } @@ -2859,7 +2859,7 @@ export { getPolicyName, getPolicyType, isArchivedRoom, - isExpensifyChatReport, + isExpensifyOnlyParticipantInReport, isPolicyExpenseChatAdmin, isPolicyAdmin, isPublicRoom, diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index 0a7d6f612f5c..827cf3aebbb8 100644 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -452,7 +452,7 @@ class ReportActionCompose extends React.Component { */ getTaskOption() { // We only prevent the task option from showing if it's a DM and the other user is an Expensify default email - if (!Permissions.canUseTasks(this.props.betas) || ReportUtils.isExpensifyChatReport(this.props.report)) { + if (!Permissions.canUseTasks(this.props.betas) || ReportUtils.isExpensifyOnlyParticipantInReport(this.props.report)) { return []; } diff --git a/src/pages/tasks/TaskShareDestinationSelectorModal.js b/src/pages/tasks/TaskShareDestinationSelectorModal.js index 35cfff25132a..00bae2db9d81 100644 --- a/src/pages/tasks/TaskShareDestinationSelectorModal.js +++ b/src/pages/tasks/TaskShareDestinationSelectorModal.js @@ -53,7 +53,7 @@ function TaskShareDestinationSelectorModal(props) { if ( !ReportUtils.isAllowedToComment(props.reports[reportKey]) || ReportUtils.isArchivedRoom(props.reports[reportKey]) || - ReportUtils.isExpensifyChatReport(props.reports[reportKey]) + ReportUtils.isExpensifyOnlyParticipantInReport(props.reports[reportKey]) ) { return; } From ce779cc4c9ea6cb5d65a8fe34d011fcae2ec1d71 Mon Sep 17 00:00:00 2001 From: Thanos30 Date: Thu, 3 Aug 2023 22:26:42 +0300 Subject: [PATCH 15/16] remove unneeded space --- src/libs/ReportUtils.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 9d08ca7d6b75..f768bed9138c 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -465,7 +465,6 @@ function isConciergeChatReport(report) { * @param {Object} report * @returns {Boolean} */ - function isExpensifyOnlyParticipantInReport(report) { const reportParticipants = _.without(lodashGet(report, 'participantAccountIDs', []), currentUserAccountID); return lodashGet(report, 'participantAccountIDs', []).length === 1 && _.some(reportParticipants, (accountID) => _.contains(CONST.EXPENSIFY_ACCOUNT_IDS, accountID)); From 18daf91b09767ffcd5d00c79866fabb452c57daa Mon Sep 17 00:00:00 2001 From: Thanos30 Date: Thu, 3 Aug 2023 23:45:49 +0300 Subject: [PATCH 16/16] remove space --- src/pages/tasks/TaskShareDestinationSelectorModal.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/tasks/TaskShareDestinationSelectorModal.js b/src/pages/tasks/TaskShareDestinationSelectorModal.js index 00bae2db9d81..8272406b4cbe 100644 --- a/src/pages/tasks/TaskShareDestinationSelectorModal.js +++ b/src/pages/tasks/TaskShareDestinationSelectorModal.js @@ -5,7 +5,6 @@ import {View} from 'react-native'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import OptionsSelector from '../../components/OptionsSelector'; - import * as OptionsListUtils from '../../libs/OptionsListUtils'; import ONYXKEYS from '../../ONYXKEYS'; import styles from '../../styles/styles';