From edfc7e6b1025964a6a345f86e14b094635070774 Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Fri, 8 Apr 2022 15:46:48 -0400 Subject: [PATCH 01/27] Use latest name from Onyx in policyExpenseChats --- src/libs/actions/Report.js | 9 ++------- src/libs/reportUtils.js | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index d98f62c4aa21..c6ab565a29de 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -160,14 +160,9 @@ function getChatReportName(fullReport, chatType) { return LoginUtils.getEmailWithoutMergedAccountPrefix(fullReport.reportName); } + // We can store whatever title for the report object since we'll create the real name based on the latest data in Onyx if (ReportUtils.isPolicyExpenseChat({chatType})) { - return `${LoginUtils.getEmailWithoutMergedAccountPrefix(fullReport.reportName)}${(ReportUtils.isArchivedRoom({ - chatType, - stateNum: fullReport.state, - statusNum: fullReport.status, - }) - ? ` (${Localize.translateLocal('common.archived')})` - : '')}`; + return fullReport.reportName; } const {sharedReportList} = fullReport; diff --git a/src/libs/reportUtils.js b/src/libs/reportUtils.js index 6ca7ecf24530..6b9c5f4c2502 100644 --- a/src/libs/reportUtils.js +++ b/src/libs/reportUtils.js @@ -5,6 +5,8 @@ import Onyx from 'react-native-onyx'; import ONYXKEYS from '../ONYXKEYS'; import CONST from '../CONST'; import * as Localize from './Localize'; +import * as PersonalDetails from './actions/PersonalDetails'; + let sessionEmail; Onyx.connect({ @@ -189,6 +191,19 @@ function getPolicyName(report, policies) { return lodashGet(policies, [`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`, 'name'], defaultValue); } +/** + * Get the title for a policyExpenseChat + * @param {Object} report + * @param {Object} policies must have Onyxkey prefix (i.e. 'policy_') for keys + * @param {Object} personalDetails must be keyed by email + */ +function getPolicyExpenseChatTitle(report, policies) { + if (report.isOwnPolicyExpenseChat) { + return getPolicyName(report, policies); + } + return PersonalDetails.getDisplayName(report.ownerEmail); +} + /** * Get either the policyName or domainName the chat is tied to * @param {Object} report @@ -320,6 +335,7 @@ export { isChatRoom, getChatRoomSubtitle, getPolicyName, + getPolicyExpenseChatTitle, isArchivedRoom, isConciergeChatReport, hasExpensifyEmails, From 2c273c3614e588159945f661251c804f70449c55 Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Wed, 13 Apr 2022 20:58:20 -0400 Subject: [PATCH 02/27] Use policyExpenseChat title in HeaderView --- src/pages/home/HeaderView.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index dd7c58ac2440..a698d3bf00f3 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -88,9 +88,14 @@ const HeaderView = (props) => { ); const isChatRoom = ReportUtils.isChatRoom(props.report); const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(props.report); - const title = (isChatRoom || isPolicyExpenseChat) - ? props.report.reportName - : _.map(displayNamesWithTooltips, ({displayName}) => displayName).join(', '); + let title; + if (isChatRoom) { + title = props.report.reportName; + } else if (isPolicyExpenseChat) { + title = ReportUtils.getPolicyExpenseChatName(props.report); + } else { + title = _.map(displayNamesWithTooltips, ({displayName}) => displayName).join(', '); + } const subtitle = ReportUtils.getChatRoomSubtitle(props.report, props.policies); const isConcierge = participants.length === 1 && _.contains(participants, CONST.EMAIL.CONCIERGE); From 0c5ecbe27da33709d2fa36308c154d9d44240fdd Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Thu, 14 Apr 2022 15:11:57 -0400 Subject: [PATCH 03/27] Move function to avoid cyclic dependency --- src/libs/actions/Report.js | 17 ++++++++++++++++- src/libs/reportUtils.js | 15 --------------- src/pages/home/HeaderView.js | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 8472fa0d6b37..0a4d7ecf801e 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -160,7 +160,8 @@ function getChatReportName(fullReport, chatType) { return LoginUtils.getEmailWithoutMergedAccountPrefix(fullReport.reportName); } - // We can store whatever title for the report object since we'll create the real name based on the latest data in Onyx + // We can store whatever title for the report object since we'll grab the latest most accurate + // name using getPolicyExpenseChatTitle if (ReportUtils.isPolicyExpenseChat({chatType})) { return fullReport.reportName; } @@ -1560,6 +1561,19 @@ function renameReport(reportID, reportName) { .finally(() => Onyx.set(ONYXKEYS.IS_LOADING_RENAME_POLICY_ROOM, false)); } +/** + * Get the title for a policyExpenseChat + * @param {Object} report + * @param {Object} policies must have Onyxkey prefix (i.e. 'policy_') for keys + */ + function getPolicyExpenseChatTitle(report, policies) { + if (report.isOwnPolicyExpenseChat) { + return ReportUtils.getPolicyName(report, policies); + } + return PersonalDetails.getDisplayName(report.ownerEmail); +} + + export { fetchAllReports, fetchActions, @@ -1591,4 +1605,5 @@ export { createPolicyRoom, renameReport, getLastReadSequenceNumber, + getPolicyExpenseChatTitle, }; diff --git a/src/libs/reportUtils.js b/src/libs/reportUtils.js index 6b9c5f4c2502..599371f13622 100644 --- a/src/libs/reportUtils.js +++ b/src/libs/reportUtils.js @@ -5,7 +5,6 @@ import Onyx from 'react-native-onyx'; import ONYXKEYS from '../ONYXKEYS'; import CONST from '../CONST'; import * as Localize from './Localize'; -import * as PersonalDetails from './actions/PersonalDetails'; let sessionEmail; @@ -191,19 +190,6 @@ function getPolicyName(report, policies) { return lodashGet(policies, [`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`, 'name'], defaultValue); } -/** - * Get the title for a policyExpenseChat - * @param {Object} report - * @param {Object} policies must have Onyxkey prefix (i.e. 'policy_') for keys - * @param {Object} personalDetails must be keyed by email - */ -function getPolicyExpenseChatTitle(report, policies) { - if (report.isOwnPolicyExpenseChat) { - return getPolicyName(report, policies); - } - return PersonalDetails.getDisplayName(report.ownerEmail); -} - /** * Get either the policyName or domainName the chat is tied to * @param {Object} report @@ -335,7 +321,6 @@ export { isChatRoom, getChatRoomSubtitle, getPolicyName, - getPolicyExpenseChatTitle, isArchivedRoom, isConciergeChatReport, hasExpensifyEmails, diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index a698d3bf00f3..69cac77ee405 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -92,7 +92,7 @@ const HeaderView = (props) => { if (isChatRoom) { title = props.report.reportName; } else if (isPolicyExpenseChat) { - title = ReportUtils.getPolicyExpenseChatName(props.report); + title = Report.getPolicyExpenseChatTitle(props.report); } else { title = _.map(displayNamesWithTooltips, ({displayName}) => displayName).join(', '); } From f79a57339abade36ab5e76f6ef8b321367e51f3b Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Thu, 14 Apr 2022 15:34:47 -0400 Subject: [PATCH 04/27] Fix policyExpenseChat name in LHN --- src/libs/OptionsListUtils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 9907efae229e..9549cb785daf 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -6,6 +6,7 @@ import lodashOrderBy from 'lodash/orderBy'; import Str from 'expensify-common/lib/str'; import ONYXKEYS from '../ONYXKEYS'; import CONST from '../CONST'; +import * as Report from './actions/Report'; import * as ReportUtils from './reportUtils'; import * as Localize from './Localize'; import Permissions from './Permissions'; @@ -275,7 +276,7 @@ function createOption(personalDetailList, report, { let text; let alternateText; if (isChatRoom || isPolicyExpenseChat) { - text = (isArchivedRoom && report.isOwnPolicyExpenseChat) ? report.oldPolicyName : lodashGet(report, ['reportName'], ''); + text = isPolicyExpenseChat ? Report.getPolicyExpenseChatTitle(report, policies) : lodashGet(report, ['reportName'], ''); alternateText = (showChatPreviewLine && !forcePolicyNamePreview && lastMessageText) ? lastMessageText : subtitle; From 5038ade921db93a5276ef9ba96807f61c2bd6893 Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Thu, 14 Apr 2022 15:38:58 -0400 Subject: [PATCH 05/27] Style fixes for whitespace and returntype --- src/libs/actions/Report.js | 4 ++-- src/libs/reportUtils.js | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 0a4d7ecf801e..b2df617acd64 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1565,15 +1565,15 @@ function renameReport(reportID, reportName) { * Get the title for a policyExpenseChat * @param {Object} report * @param {Object} policies must have Onyxkey prefix (i.e. 'policy_') for keys + * @returns {String} */ - function getPolicyExpenseChatTitle(report, policies) { +function getPolicyExpenseChatTitle(report, policies) { if (report.isOwnPolicyExpenseChat) { return ReportUtils.getPolicyName(report, policies); } return PersonalDetails.getDisplayName(report.ownerEmail); } - export { fetchAllReports, fetchActions, diff --git a/src/libs/reportUtils.js b/src/libs/reportUtils.js index 599371f13622..6ca7ecf24530 100644 --- a/src/libs/reportUtils.js +++ b/src/libs/reportUtils.js @@ -6,7 +6,6 @@ import ONYXKEYS from '../ONYXKEYS'; import CONST from '../CONST'; import * as Localize from './Localize'; - let sessionEmail; Onyx.connect({ key: ONYXKEYS.SESSION, From 3579468d4e0493a15073672e816303d7c1e5b021 Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Wed, 18 May 2022 11:35:25 -0400 Subject: [PATCH 06/27] Fix import casing --- src/libs/OptionsListUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 2c8bc4afdf1e..b01ac4a274bf 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -6,7 +6,7 @@ import lodashOrderBy from 'lodash/orderBy'; import Str from 'expensify-common/lib/str'; import ONYXKEYS from '../ONYXKEYS'; import CONST from '../CONST'; -import * as ReportUtils from './reportUtils'; +import * as ReportUtils from './ReportUtils'; import * as Localize from './Localize'; import Permissions from './Permissions'; import * as CollectionUtils from './CollectionUtils'; From a7a15e1222db452ffeca6760a80171438d4a7d4d Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Thu, 26 May 2022 14:27:30 -0400 Subject: [PATCH 07/27] Remove reportnamevaluepair check since reports in onyx don't have them --- src/libs/ReportUtils.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 144962be04ca..2c152fa122d6 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -451,10 +451,6 @@ function getDisplayNamesWithTooltips(participants, isMultipleParticipantReport) * @returns {String} */ function getReportName(report, personalDetailsForParticipants = {}, policies = {}) { - if (lodashGet(report, 'reportNameValuePairs.type') !== 'chat') { - return lodashGet(report, 'reportName', ''); - } - let formattedName; if (isChatRoom(report)) { formattedName = `#${report.reportName}`; From 4730c252ba9db7661a91b0ed84ebc88c3b6bcb88 Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Thu, 26 May 2022 14:27:57 -0400 Subject: [PATCH 08/27] Fix double #'ed chat room names --- src/libs/ReportUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 2c152fa122d6..0ddd6fd84b8c 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -453,7 +453,7 @@ function getDisplayNamesWithTooltips(participants, isMultipleParticipantReport) function getReportName(report, personalDetailsForParticipants = {}, policies = {}) { let formattedName; if (isChatRoom(report)) { - formattedName = `#${report.reportName}`; + formattedName = `${report.reportName}`; } if (isPolicyExpenseChat(report)) { From 04e2db45b3f38b0dd9cadbf89e8168c5bca4eadf Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Thu, 26 May 2022 14:28:56 -0400 Subject: [PATCH 09/27] Fix blank report header view --- src/pages/home/HeaderView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index bf53157b86f6..c15a03ba7a94 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -106,7 +106,7 @@ const HeaderView = (props) => { )} - {Boolean(props.report && props.report.reportName) && ( + {Boolean(props.report && title) && ( Date: Thu, 26 May 2022 14:30:06 -0400 Subject: [PATCH 10/27] Remove unused code --- src/pages/home/HeaderView.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index c15a03ba7a94..9ad36b43b38b 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -73,14 +73,6 @@ const HeaderView = (props) => { const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(participantPersonalDetails, isMultipleParticipant); const isChatRoom = ReportUtils.isChatRoom(props.report); const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(props.report); - // let title; - // if (isChatRoom) { - // title = props.report.reportName; - // } else if (isPolicyExpenseChat) { - // title = Report.getPolicyExpenseChatTitle(props.report); - // } else { - // title = _.map(displayNamesWithTooltips, ({displayName}) => displayName).join(', '); - // } const title = ReportUtils.getReportName(props.report, participantPersonalDetails, props.policies); const subtitle = ReportUtils.getChatRoomSubtitle(props.report, props.policies); From b3fa99ac9585ee699adb05739dc324f836258aaa Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Fri, 27 May 2022 12:49:37 -0400 Subject: [PATCH 11/27] Remove unecessary getPolicyExpenseChatTitle --- src/libs/OptionsListUtils.js | 1 - src/libs/actions/Report.js | 16 ---------------- 2 files changed, 17 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index b01ac4a274bf..339dd2c6e259 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -252,7 +252,6 @@ function createOption(logins, personalDetails, report, { let text; let alternateText; if (isChatRoom || isPolicyExpenseChat) { - // text = isPolicyExpenseChat ? Report.getPolicyExpenseChatTitle(report, policies) : lodashGet(report, ['reportName'], ''); text = lodashGet(report, 'reportName') || lodashGet(report, 'oldPolicyName', ''); alternateText = (showChatPreviewLine && !forcePolicyNamePreview && lastMessageText) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index e58fc1defa61..c64d9a630cbf 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -161,8 +161,6 @@ function getChatReportName(fullReport, chatType, oldPolicyName) { return LoginUtils.getEmailWithoutMergedAccountPrefix(fullReport.reportName); } - // We can store whatever title for the report object since we'll grab the latest most accurate - // name using getPolicyExpenseChatTitle if (ReportUtils.isPolicyExpenseChat({chatType})) { const name = (isArchivedRoom && fullReport.isOwnPolicyExpenseChat) ? oldPolicyName @@ -1571,19 +1569,6 @@ function renameReport(reportID, reportName) { .finally(() => Onyx.set(ONYXKEYS.IS_LOADING_RENAME_POLICY_ROOM, false)); } -/** - * Get the title for a policyExpenseChat - * @param {Object} report - * @param {Object} policies must have Onyxkey prefix (i.e. 'policy_') for keys - * @returns {String} - */ -function getPolicyExpenseChatTitle(report, policies) { - if (report.isOwnPolicyExpenseChat) { - return ReportUtils.getPolicyName(report, policies); - } - return PersonalDetails.getDisplayName(report.ownerEmail); -} - export { fetchAllReports, fetchActions, @@ -1615,5 +1600,4 @@ export { createPolicyRoom, renameReport, getLastReadSequenceNumber, - getPolicyExpenseChatTitle, }; From 1b89044c2227dc080932ec1e49d058b4eeb5fe60 Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Fri, 27 May 2022 13:04:14 -0400 Subject: [PATCH 12/27] Use getReportName when building options --- src/libs/OptionsListUtils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 339dd2c6e259..a68c9027b82e 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -220,7 +220,8 @@ function createOption(logins, personalDetails, report, { }) { const isChatRoom = ReportUtils.isChatRoom(report); const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report); - const personalDetailList = _.values(getPersonalDetailsForLogins(logins, personalDetails)); + const personalDetailMap = getPersonalDetailsForLogins(logins, personalDetails); + const personalDetailList = _.values(personalDetailMap); const isArchivedRoom = ReportUtils.isArchivedRoom(report); const hasMultipleParticipants = personalDetailList.length > 1 || isChatRoom || isPolicyExpenseChat; const personalDetail = personalDetailList[0]; @@ -252,8 +253,7 @@ function createOption(logins, personalDetails, report, { let text; let alternateText; if (isChatRoom || isPolicyExpenseChat) { - text = lodashGet(report, 'reportName') - || lodashGet(report, 'oldPolicyName', ''); + text = ReportUtils.getReportName(report, personalDetailMap, policies); alternateText = (showChatPreviewLine && !forcePolicyNamePreview && lastMessageText) ? lastMessageText : subtitle; From 91e76463b725ef7638da15921aaa2a4645b7879d Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Fri, 27 May 2022 13:07:17 -0400 Subject: [PATCH 13/27] Use getReportName in ReportDetailsPage --- src/pages/ReportDetailsPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/ReportDetailsPage.js b/src/pages/ReportDetailsPage.js index e6b171c03329..6a1ca6f60899 100644 --- a/src/pages/ReportDetailsPage.js +++ b/src/pages/ReportDetailsPage.js @@ -132,7 +132,7 @@ class ReportDetailsPage extends Component { Date: Fri, 27 May 2022 13:19:05 -0400 Subject: [PATCH 14/27] Use getReportName in ReportWelcomeText --- src/components/ReportWelcomeText.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportWelcomeText.js b/src/components/ReportWelcomeText.js index 528397ade9c6..631d80fd9b51 100644 --- a/src/components/ReportWelcomeText.js +++ b/src/components/ReportWelcomeText.js @@ -89,7 +89,7 @@ const ReportWelcomeText = (props) => { {roomWelcomeMessage.phrase1} Navigation.navigate(ROUTES.getReportDetailsRoute(props.report.reportID))}> - {props.report.reportName} + {ReportUtils.getReportName(props.report, props.personalDetails, props.policies)} {roomWelcomeMessage.phrase2} From 9ab4d8d38152d02befc54fd361f8fac5bfa28e47 Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Fri, 27 May 2022 13:28:54 -0400 Subject: [PATCH 15/27] Make tests accomodate Onyx Reports created from Report.getChatReportName --- src/libs/ReportUtils.js | 2 +- tests/unit/ReportUtilsTest.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 0ddd6fd84b8c..44da73a5c8ee 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -453,7 +453,7 @@ function getDisplayNamesWithTooltips(participants, isMultipleParticipantReport) function getReportName(report, personalDetailsForParticipants = {}, policies = {}) { let formattedName; if (isChatRoom(report)) { - formattedName = `${report.reportName}`; + formattedName = report.reportName; } if (isPolicyExpenseChat(report)) { diff --git a/tests/unit/ReportUtilsTest.js b/tests/unit/ReportUtilsTest.js index e2f9fefbda52..80160d598612 100644 --- a/tests/unit/ReportUtilsTest.js +++ b/tests/unit/ReportUtilsTest.js @@ -132,7 +132,7 @@ describe('ReportUtils', () => { const baseAdminsRoom = { ...REPORT_TYPE_CHAT, chatType: CONST.REPORT.CHAT_TYPE.POLICY_ADMINS, - reportName: 'admins', + reportName: '#admins', }; test('Active', () => { @@ -157,7 +157,7 @@ describe('ReportUtils', () => { const baseUserCreatedRoom = { ...REPORT_TYPE_CHAT, chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, - reportName: 'VikingsChat', + reportName: '#VikingsChat', }; test('Active', () => { From e5112f866a0e73965eb91648f5490cdf8fc9e50e Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Fri, 27 May 2022 14:10:36 -0400 Subject: [PATCH 16/27] Remove redundant getChatReportName and put logic in getReportName --- src/libs/ReportUtils.js | 10 +++++++- src/libs/actions/Report.js | 45 +---------------------------------- tests/unit/ReportUtilsTest.js | 2 +- 3 files changed, 11 insertions(+), 46 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 44da73a5c8ee..3a1b1c8f7f91 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -451,8 +451,16 @@ function getDisplayNamesWithTooltips(participants, isMultipleParticipantReport) * @returns {String} */ function getReportName(report, personalDetailsForParticipants = {}, policies = {}) { + if (_.isEmpty(report.chatType)) { + return report.reportName; + } + let formattedName; - if (isChatRoom(report)) { + if (isDefaultRoom(report)) { + formattedName = `#${report.reportName}`; + } + + if (isUserCreatedPolicyRoom(report)) { formattedName = report.reportName; } diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index c64d9a630cbf..861d53e7e83b 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -137,46 +137,6 @@ function getParticipantEmailsFromReport({sharedReportList, reportNameValuePairs, return _.without(emailArray, currentUserEmail); } -/** - * Returns the title for a default room, a policy room or generates one based on the participants - * - * @param {Object} fullReport - * @param {String} chatType - * @param {String} oldPolicyName - * @return {String} - */ -function getChatReportName(fullReport, chatType, oldPolicyName) { - const isArchivedRoom = ReportUtils.isArchivedRoom({ - chatType, - stateNum: fullReport.state, - statusNum: fullReport.status, - }); - - if (ReportUtils.isDefaultRoom({chatType})) { - return `#${fullReport.reportName}${isArchivedRoom ? ` (${Localize.translateLocal('common.deleted')})` : ''}`; - } - - // For a basic policy room, return its original name - if (ReportUtils.isUserCreatedPolicyRoom({chatType})) { - return LoginUtils.getEmailWithoutMergedAccountPrefix(fullReport.reportName); - } - - if (ReportUtils.isPolicyExpenseChat({chatType})) { - const name = (isArchivedRoom && fullReport.isOwnPolicyExpenseChat) - ? oldPolicyName - : LoginUtils.getEmailWithoutMergedAccountPrefix(lodashGet(fullReport, ['reportName'], '')); - return `${name}${isArchivedRoom ? ` (${Localize.translateLocal('common.archived')})` : ''}`; - } - - const {sharedReportList} = fullReport; - return _.chain(sharedReportList) - .map(participant => participant.email) - .filter(participant => participant !== currentUserEmail) - .map(participant => PersonalDetails.getDisplayName(participant)) - .value() - .join(', '); -} - /** * Only store the minimal amount of data in Onyx that needs to be stored * because space is limited @@ -208,9 +168,6 @@ function getSimplifiedReportObject(report) { // Used for archived rooms, will store the policy name that the room used to belong to. const oldPolicyName = lodashGet(report, ['reportNameValuePairs', 'oldPolicyName'], ''); - const reportName = lodashGet(report, ['reportNameValuePairs', 'type']) === 'chat' - ? getChatReportName(report, chatType, oldPolicyName) - : report.reportName; const lastActorEmail = lodashGet(report, 'lastActionActorEmail', ''); const notificationPreference = ReportUtils.isChatRoom({chatType}) ? lodashGet(report, ['reportNameValuePairs', 'notificationPreferences', currentUserAccountID], 'daily') @@ -221,7 +178,7 @@ function getSimplifiedReportObject(report) { return { reportID: report.reportID, - reportName, + reportName: report.reportName, chatType, ownerEmail: LoginUtils.getEmailWithoutMergedAccountPrefix(lodashGet(report, ['ownerEmail'], '')), policyID: lodashGet(report, ['reportNameValuePairs', 'expensify_policyID'], ''), diff --git a/tests/unit/ReportUtilsTest.js b/tests/unit/ReportUtilsTest.js index 80160d598612..07c364fb2298 100644 --- a/tests/unit/ReportUtilsTest.js +++ b/tests/unit/ReportUtilsTest.js @@ -132,7 +132,7 @@ describe('ReportUtils', () => { const baseAdminsRoom = { ...REPORT_TYPE_CHAT, chatType: CONST.REPORT.CHAT_TYPE.POLICY_ADMINS, - reportName: '#admins', + reportName: 'admins', }; test('Active', () => { From 706be32597126d046047f379c80e0a3c99aceb29 Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Fri, 27 May 2022 14:30:07 -0400 Subject: [PATCH 17/27] Update OptionListUtils test to use standard reportName in Onyx and policies --- tests/unit/OptionsListUtilsTest.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tests/unit/OptionsListUtilsTest.js b/tests/unit/OptionsListUtilsTest.js index 1ea4fe9fe02e..cc504dad68ff 100644 --- a/tests/unit/OptionsListUtilsTest.js +++ b/tests/unit/OptionsListUtilsTest.js @@ -111,6 +111,7 @@ describe('OptionsListUtils', () => { reportName: '', oldPolicyName: "SHIELD's workspace", chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, + isOwnPolicyExpenseChat: true, }, }; @@ -259,6 +260,11 @@ describe('OptionsListUtils', () => { }, }; + const POLICY = { + policyID: 'ABC123', + name: 'Hero Policy', + } + // Set the currently logged in user, report data, and personal details beforeAll(() => { Onyx.init({ @@ -269,6 +275,7 @@ describe('OptionsListUtils', () => { ownerEmail: 'mistersinister@marauders.com', total: '1000', }, + [`${ONYXKEYS.COLLECTION.POLICY}${POLICY.policyID}`]: POLICY }, }); Onyx.registerLogger(() => {}); @@ -707,9 +714,9 @@ describe('OptionsListUtils', () => { lastMessageTimestamp: 0, lastVisitedTimestamp: 1610666739302, participants: ['test3@instantworkspace.com'], - policyID: 'Whatever', + policyID: 'ABC123', reportID: 10, - reportName: "Someone's workspace", + reportName: '', unreadActionCount: 0, visibility: undefined, }, @@ -723,9 +730,9 @@ describe('OptionsListUtils', () => { lastMessageTimestamp: 0, lastVisitedTimestamp: 1610666739302, participants: ['test3@instantworkspace.com'], - policyID: 'Whatever', + policyID: 'ABC123', reportID: 11, - reportName: "Someone's workspace", + reportName: '', unreadActionCount: 0, visibility: undefined, stateNum: CONST.REPORT.STATE_NUM.SUBMITTED, @@ -740,9 +747,9 @@ describe('OptionsListUtils', () => { lastMessageTimestamp: 0, lastVisitedTimestamp: 1610666739302, participants: ['test3@instantworkspace.com'], - policyID: 'Whatever', + policyID: 'ABC123', reportID: 12, - reportName: '#admins', + reportName: 'admins', unreadActionCount: 0, visibility: undefined, }, @@ -755,9 +762,9 @@ describe('OptionsListUtils', () => { lastMessageTimestamp: 0, lastVisitedTimestamp: 1610666739302, participants: ['test3@instantworkspace.com'], - policyID: 'Whatever', + policyID: 'ABC123', reportID: 13, - reportName: '#admins', + reportName: 'admins', unreadActionCount: 0, visibility: undefined, stateNum: CONST.REPORT.STATE_NUM.SUBMITTED, @@ -777,7 +784,7 @@ describe('OptionsListUtils', () => { expect(results.recentReports.length).toBe(_.size(reportsWithEmptyChatRooms) - 2); expect(results.recentReports[0].isPolicyExpenseChat).toBe(true); - expect(results.recentReports[0].text).toBe("Someone's workspace"); + expect(results.recentReports[0].text).toBe('Hero Policy'); expect(results.recentReports[1].isChatRoom).toBe(true); expect(results.recentReports[1].text).toBe('#admins'); From be133b76aef8fc99201fbc292f88130d0887c4ec Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Fri, 27 May 2022 14:35:07 -0400 Subject: [PATCH 18/27] Clean up tests slightly --- 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 cc504dad68ff..49fcc8da861b 100644 --- a/tests/unit/OptionsListUtilsTest.js +++ b/tests/unit/OptionsListUtilsTest.js @@ -707,7 +707,7 @@ describe('OptionsListUtils', () => { const reportsWithEmptyChatRooms = { // This report is a policyExpenseChat without any messages in it (i.e. no lastMessageTimestamp) 10: { - chatType: 'policyExpenseChat', + chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, hasOutstandingIOU: false, isOwnPolicyExpenseChat: true, isPinned: false, @@ -723,7 +723,7 @@ describe('OptionsListUtils', () => { // This is an archived version of the above policyExpenseChat 11: { - chatType: 'policyExpenseChat', + chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, hasOutstandingIOU: false, isOwnPolicyExpenseChat: true, isPinned: false, From 850e647be96dd7313c3868f62a371c9a72eba2d6 Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Fri, 27 May 2022 21:27:45 -0400 Subject: [PATCH 19/27] Make function only relevant for chat reports --- src/libs/ReportUtils.js | 4 ---- tests/unit/ReportUtilsTest.js | 23 ----------------------- 2 files changed, 27 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 3a1b1c8f7f91..0a47f9693fe3 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -451,10 +451,6 @@ function getDisplayNamesWithTooltips(participants, isMultipleParticipantReport) * @returns {String} */ function getReportName(report, personalDetailsForParticipants = {}, policies = {}) { - if (_.isEmpty(report.chatType)) { - return report.reportName; - } - let formattedName; if (isDefaultRoom(report)) { formattedName = `#${report.reportName}`; diff --git a/tests/unit/ReportUtilsTest.js b/tests/unit/ReportUtilsTest.js index 07c364fb2298..8775ab0f7e1e 100644 --- a/tests/unit/ReportUtilsTest.js +++ b/tests/unit/ReportUtilsTest.js @@ -5,12 +5,6 @@ import ONYXKEYS from '../../src/ONYXKEYS'; import * as ReportUtils from '../../src/libs/ReportUtils'; import waitForPromisesToResolve from '../utils/waitForPromisesToResolve'; -const REPORT_TYPE_CHAT = { - reportNameValuePairs: { - type: CONST.REPORT.TYPE.CHAT, - }, -}; - const currentUserEmail = 'bjorn@vikings.net'; const participantsPersonalDetails = { 'ragnar@vikings.net': { @@ -101,21 +95,18 @@ describe('ReportUtils', () => { describe('1:1 DM', () => { test('with displayName', () => { expect(ReportUtils.getReportName({ - ...REPORT_TYPE_CHAT, participants: [currentUserEmail, 'ragnar@vikings.net'], }, _.pick(participantsPersonalDetails, 'ragnar@vikings.net'))).toBe('Ragnar Lothbrok'); }); test('no displayName', () => { expect(ReportUtils.getReportName({ - ...REPORT_TYPE_CHAT, participants: [currentUserEmail, 'floki@vikings.net'], }, _.pick(participantsPersonalDetails, 'floki@vikings.net'))).toBe('floki@vikings.net'); }); test('SMS', () => { expect(ReportUtils.getReportName({ - ...REPORT_TYPE_CHAT, participants: [currentUserEmail, '+12223334444@expensify.sms'], }, _.pick(participantsPersonalDetails, '+12223334444@expensify.sms'))).toBe('2223334444'); }); @@ -123,14 +114,12 @@ describe('ReportUtils', () => { test('Group DM', () => { expect(ReportUtils.getReportName({ - ...REPORT_TYPE_CHAT, participants: [currentUserEmail, 'ragnar@vikings.net', 'floki@vikings.net', 'lagertha@vikings.net', '+12223334444@expensify.sms'], }, participantsPersonalDetails)).toBe('Ragnar, floki@vikings.net, Lagertha, 2223334444'); }); describe('Default Policy Room', () => { const baseAdminsRoom = { - ...REPORT_TYPE_CHAT, chatType: CONST.REPORT.CHAT_TYPE.POLICY_ADMINS, reportName: 'admins', }; @@ -155,7 +144,6 @@ describe('ReportUtils', () => { describe('User-Created Policy Room', () => { const baseUserCreatedRoom = { - ...REPORT_TYPE_CHAT, chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, reportName: '#VikingsChat', }; @@ -182,16 +170,6 @@ describe('ReportUtils', () => { describe('Active', () => { test('as member', () => { expect(ReportUtils.getReportName({ - ...REPORT_TYPE_CHAT, - chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, - policyID: policy.policyID, - isOwnPolicyExpenseChat: true, - }, {}, policies)).toBe(policy.name); - }); - - test('as admin', () => { - expect(ReportUtils.getReportName({ - ...REPORT_TYPE_CHAT, chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, policyID: policy.policyID, isOwnPolicyExpenseChat: false, @@ -202,7 +180,6 @@ describe('ReportUtils', () => { describe('Archived', () => { const baseArchivedPolicyExpenseChat = { - ...REPORT_TYPE_CHAT, chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, ownerEmail: 'ragnar@vikings.net', policyID: policy.policyID, From 5442735ac0cf607bd8d7acd28c4d7a5942944dd7 Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Fri, 27 May 2022 22:19:28 -0400 Subject: [PATCH 20/27] lint fixes --- 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 49fcc8da861b..a07d016c2b09 100644 --- a/tests/unit/OptionsListUtilsTest.js +++ b/tests/unit/OptionsListUtilsTest.js @@ -263,7 +263,7 @@ describe('OptionsListUtils', () => { const POLICY = { policyID: 'ABC123', name: 'Hero Policy', - } + }; // Set the currently logged in user, report data, and personal details beforeAll(() => { @@ -275,7 +275,7 @@ describe('OptionsListUtils', () => { ownerEmail: 'mistersinister@marauders.com', total: '1000', }, - [`${ONYXKEYS.COLLECTION.POLICY}${POLICY.policyID}`]: POLICY + [`${ONYXKEYS.COLLECTION.POLICY}${POLICY.policyID}`]: POLICY, }, }); Onyx.registerLogger(() => {}); From b95366064bfb5582c5cd9c8cb3a145ddeaf3faa4 Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Tue, 31 May 2022 15:35:26 -0400 Subject: [PATCH 21/27] Use getReportName for all chat titles instead of doing double work --- src/libs/OptionsListUtils.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index a68c9027b82e..a55ea209bcef 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -250,18 +250,13 @@ function createOption(logins, personalDetails, report, { const tooltipText = ReportUtils.getReportParticipantsTitle(lodashGet(report, ['participants'], [])); const subtitle = ReportUtils.getChatRoomSubtitle(report, policies); - let text; + const text = ReportUtils.getReportName(report, personalDetailMap, policies); let alternateText; if (isChatRoom || isPolicyExpenseChat) { - text = ReportUtils.getReportName(report, personalDetailMap, policies); alternateText = (showChatPreviewLine && !forcePolicyNamePreview && lastMessageText) ? lastMessageText : subtitle; } else { - text = hasMultipleParticipants - ? _.map(personalDetailList, ({firstName, login}) => firstName || Str.removeSMSDomain(login)) - .join(', ') - : lodashGet(report, ['reportName'], personalDetail.displayName); alternateText = (showChatPreviewLine && lastMessageText) ? lastMessageText : Str.removeSMSDomain(personalDetail.login); From 3e495a288593b2d0f7e66fc2f1d35e72d3a627d8 Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Wed, 1 Jun 2022 15:00:49 -0400 Subject: [PATCH 22/27] Fix tests to work with name alphabetizing --- tests/unit/OptionsListUtilsTest.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/unit/OptionsListUtilsTest.js b/tests/unit/OptionsListUtilsTest.js index a07d016c2b09..c3437407ac2b 100644 --- a/tests/unit/OptionsListUtilsTest.js +++ b/tests/unit/OptionsListUtilsTest.js @@ -673,15 +673,18 @@ describe('OptionsListUtils', () => { expect(results.personalDetails.length).toBe(0); // Pinned reports are always on the top in alphabetical order regardless of whether they are unread or have IOU debt. - // D report name (Alphabetically first among pinned reports) + // Mister Fantastic report name (Alphabetically first among pinned reports) let index = 0; - expect(results.recentReports[index].login).toBe('d_email@email.com'); + expect(results.recentReports[index].text).toBe('Mister Fantastic'); + expect(results.recentReports[index].login).toBe('reedrichards@expensify.com'); - // Mister Fantastic report name (Alphabetically second among pinned reports) - expect(results.recentReports[++index].login).toBe('reedrichards@expensify.com'); + // d_email@email.com report name (Alphabetically second among pinned reports because of lowercase name) + expect(results.recentReports[++index].text).toBe('d_email@email.com'); + expect(results.recentReports[index].login).toBe('d_email@email.com'); - // Z report name (Alphabetically third among pinned reports) - expect(results.recentReports[++index].login).toBe('z_email@email.com'); + // z_email@email.com (Alphabetically third among pinned reports) + expect(results.recentReports[++index].text).toBe('z_email@email.com'); + expect(results.recentReports[index].login).toBe('z_email@email.com'); // Unpinned report name ordered alphabetically after pinned reports // Black Panther report name has unread message From aaefdf160f0ea1dd91fb27ba90124dc137bdde09 Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Wed, 1 Jun 2022 15:04:52 -0400 Subject: [PATCH 23/27] Fix tests for Captain Britain using personal detail --- tests/unit/OptionsListUtilsTest.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/unit/OptionsListUtilsTest.js b/tests/unit/OptionsListUtilsTest.js index c3437407ac2b..d152b2e2448a 100644 --- a/tests/unit/OptionsListUtilsTest.js +++ b/tests/unit/OptionsListUtilsTest.js @@ -107,7 +107,7 @@ describe('OptionsListUtils', () => { lastMessageTimestamp: 1, reportID: 10, isPinned: false, - participants: ['captain_britain@expensify.com', 'captain_america@expensify.com'], + participants: ['tonystark@expensify.com', 'steverogers@expensify.com'], reportName: '', oldPolicyName: "SHIELD's workspace", chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, @@ -620,13 +620,20 @@ describe('OptionsListUtils', () => { reportName: 'Captain Britain', }, }; + const personalDetailsWithNewParticipant = { + ...PERSONAL_DETAILS, + 'captain_britain@expensify.com': { + displayName: 'Captain Britain', + login: 'captain_britain@expensify.com', + } + } return Report.setReportWithDraft(1, true) .then(() => { // When we call getSidebarOptions() with no search value and default priority mode const results = OptionsListUtils.getSidebarOptions( reportsWithAddedPinnedMessagelessReport, - PERSONAL_DETAILS, + personalDetailsWithNewParticipant, 0, CONST.PRIORITY_MODE.DEFAULT, ); @@ -643,6 +650,7 @@ describe('OptionsListUtils', () => { // And the most recent pinned report is first in the list of reports let index = 0; + expect(results.recentReports[index].text).toBe('Captain Britain'); expect(results.recentReports[index].login).toBe('captain_britain@expensify.com'); // And the third report is the report with an IOU debt @@ -650,7 +658,7 @@ describe('OptionsListUtils', () => { expect(results.recentReports[index].login).toBe('mistersinister@marauders.com'); // And the fourth report is the report with a draft comment - expect(results.recentReports[++index].text).toBe('tonystark@expensify.com, reedrichards@expensify.com'); + expect(results.recentReports[++index].text).toBe('Iron Man, Mister Fantastic'); // And the fifth report is the report with the lastMessage timestamp expect(results.recentReports[++index].login).toBe('steverogers@expensify.com'); From 5493a377f9e2b6faab1c57a70bdd4303b053b1e7 Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Wed, 1 Jun 2022 15:07:24 -0400 Subject: [PATCH 24/27] Fix searching for options using reportName --- src/libs/OptionsListUtils.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index a55ea209bcef..e5766032250e 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -163,11 +163,12 @@ function getParticipantNames(personalDetailList) { * Default should be serachable by policy/domain name but not by participants. * * @param {Object} report + * @param {String} reportName * @param {Array} personalDetailList * @param {Boolean} isChatRoomOrPolicyExpenseChat * @return {String} */ -function getSearchText(report, personalDetailList, isChatRoomOrPolicyExpenseChat) { +function getSearchText(report, reportName, personalDetailList, isChatRoomOrPolicyExpenseChat) { const searchTerms = []; if (!isChatRoomOrPolicyExpenseChat) { @@ -177,8 +178,8 @@ function getSearchText(report, personalDetailList, isChatRoomOrPolicyExpenseChat }); } if (report) { - searchTerms.push(...report.reportName); - searchTerms.push(..._.map(report.reportName.split(','), name => name.trim())); + searchTerms.push(...reportName); + searchTerms.push(..._.map(reportName.split(','), name => name.trim())); if (isChatRoomOrPolicyExpenseChat) { const chatRoomSubtitle = ReportUtils.getChatRoomSubtitle(report, policies); @@ -250,7 +251,7 @@ function createOption(logins, personalDetails, report, { const tooltipText = ReportUtils.getReportParticipantsTitle(lodashGet(report, ['participants'], [])); const subtitle = ReportUtils.getChatRoomSubtitle(report, policies); - const text = ReportUtils.getReportName(report, personalDetailMap, policies); + const reportName = ReportUtils.getReportName(report, personalDetailMap, policies); let alternateText; if (isChatRoom || isPolicyExpenseChat) { alternateText = (showChatPreviewLine && !forcePolicyNamePreview && lastMessageText) @@ -262,7 +263,7 @@ function createOption(logins, personalDetails, report, { : Str.removeSMSDomain(personalDetail.login); } return { - text, + text: reportName, alternateText, icons: ReportUtils.getIcons(report, personalDetails, policies, lodashGet(personalDetail, ['avatar'])), tooltipText, @@ -279,7 +280,7 @@ function createOption(logins, personalDetails, report, { isUnread: report ? report.unreadActionCount > 0 : null, hasDraftComment, keyForList: report ? String(report.reportID) : personalDetail.login, - searchText: getSearchText(report, personalDetailList, isChatRoom || isPolicyExpenseChat), + searchText: getSearchText(report, reportName, personalDetailList, isChatRoom || isPolicyExpenseChat), isPinned: lodashGet(report, 'isPinned', false), hasOutstandingIOU, iouReportID: lodashGet(report, 'iouReportID'), From 9fd17a1ea0186941a88d780ae3401e291b9bb086 Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Wed, 1 Jun 2022 15:26:07 -0400 Subject: [PATCH 25/27] Lint fixes --- 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 d152b2e2448a..4975fa2b0025 100644 --- a/tests/unit/OptionsListUtilsTest.js +++ b/tests/unit/OptionsListUtilsTest.js @@ -625,8 +625,8 @@ describe('OptionsListUtils', () => { 'captain_britain@expensify.com': { displayName: 'Captain Britain', login: 'captain_britain@expensify.com', - } - } + }, + }; return Report.setReportWithDraft(1, true) .then(() => { From e15edaa51046224735cdbba0c92d95b9f4ff59c8 Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Wed, 1 Jun 2022 15:27:08 -0400 Subject: [PATCH 26/27] Remove deleted translation which is no longer used --- src/languages/en.js | 1 - src/languages/es.js | 1 - 2 files changed, 2 deletions(-) diff --git a/src/languages/en.js b/src/languages/en.js index f3c028c8a5d8..99166fdca0fa 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -37,7 +37,6 @@ export default { privacy: 'Privacy', privacyPolicy: 'Privacy policy', delete: 'Delete', - deleted: 'deleted', archived: 'archived', contacts: 'Contacts', recents: 'Recents', diff --git a/src/languages/es.js b/src/languages/es.js index f968c28ac221..2c3ba17d6975 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -37,7 +37,6 @@ export default { privacy: 'Privacidad', privacyPolicy: 'PolĂ­tica de privacidad', delete: 'Eliminar', - deleted: 'eliminado', archived: 'archivado', contacts: 'Contactos', recents: 'Recientes', From 004b6d081405d24546546b93c005ce5733c2fdbf Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Fri, 3 Jun 2022 10:07:30 -0400 Subject: [PATCH 27/27] Fix policyExpenseChat tests --- tests/unit/ReportUtilsTest.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/unit/ReportUtilsTest.js b/tests/unit/ReportUtilsTest.js index 8775ab0f7e1e..7f872a012b6a 100644 --- a/tests/unit/ReportUtilsTest.js +++ b/tests/unit/ReportUtilsTest.js @@ -169,6 +169,15 @@ describe('ReportUtils', () => { describe('PolicyExpenseChat', () => { describe('Active', () => { test('as member', () => { + expect(ReportUtils.getReportName({ + chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, + policyID: policy.policyID, + isOwnPolicyExpenseChat: true, + ownerEmail: 'ragnar@vikings.net', + }, participantsPersonalDetails, policies)).toBe('Vikings Policy'); + }); + + test('as admin', () => { expect(ReportUtils.getReportName({ chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, policyID: policy.policyID,