From 4f3ab3cd1d81922f28d2fa4920a8388eb79851c6 Mon Sep 17 00:00:00 2001 From: Francois Laithier Date: Fri, 26 Apr 2024 17:59:54 -0700 Subject: [PATCH 1/2] Allow system account chat to be listed in LHN, fix chat icons --- src/CONST.ts | 1 + src/libs/OptionsListUtils.ts | 7 +------ src/libs/ReportUtils.ts | 15 +++++++++++++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 8e356be6df29..d59f32f3c3ce 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -55,6 +55,7 @@ const chatTypes = { POLICY_ROOM: 'policyRoom', POLICY_EXPENSE_CHAT: 'policyExpenseChat', SELF_DM: 'selfDM', + SYSTEM_DM: 'system', } as const; // Explicit type annotation is required diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 8166036e8e17..7696615e3138 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1724,7 +1724,7 @@ function getOptions( allPersonalDetailsOptions = lodashOrderBy(allPersonalDetailsOptions, [(personalDetail) => personalDetail.text?.toLowerCase()], 'asc'); } - const optionsToExclude: Option[] = [{login: CONST.EMAIL.NOTIFICATIONS}]; + const optionsToExclude: Option[] = []; // If we're including selected options from the search results, we only want to exclude them if the search input is empty // This is because on certain pages, we show the selected options at the top when the search input is empty @@ -1753,11 +1753,6 @@ function getOptions( break; } - // Skip notifications@expensify.com - if (reportOption.login === CONST.EMAIL.NOTIFICATIONS) { - continue; - } - const isCurrentUserOwnedPolicyExpenseChatThatCouldShow = reportOption.isPolicyExpenseChat && reportOption.ownerAccountID === currentUserAccountID && includeOwnedWorkspaceChats && !reportOption.isArchivedRoom; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 764105f8c175..f81520ac0e3b 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -973,6 +973,10 @@ function isSelfDM(report: OnyxEntry): boolean { return getChatType(report) === CONST.REPORT.CHAT_TYPE.SELF_DM; } +function isSystemDM(report: OnyxEntry): boolean { + return getChatType(report) === CONST.REPORT.CHAT_TYPE.SYSTEM_DM; +} + function isGroupChat(report: OnyxEntry | Partial): boolean { return getChatType(report) === CONST.REPORT.CHAT_TYPE.GROUP; } @@ -1944,6 +1948,10 @@ function getIcons( return getIconsForParticipants([currentUserAccountID ?? 0], personalDetails); } + if (isSystemDM(report)) { + return getIconsForParticipants([CONST.ACCOUNT_ID.NOTIFICATIONS ?? 0], personalDetails); + } + if (isGroupChat(report)) { const groupChatIcon = { // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing @@ -3039,6 +3047,10 @@ function getReportName(report: OnyxEntry, policy: OnyxEntry = nu formattedName = getDisplayNameForParticipant(currentUserAccountID, undefined, undefined, true); } + if (isSystemDM(report)) { + formattedName = getDisplayNameForParticipant(CONST.ACCOUNT_ID.NOTIFICATIONS); + } + if (formattedName) { return formattedName; } @@ -4804,8 +4816,6 @@ function shouldReportBeInOptionList({ report?.reportName === undefined || // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing report?.isHidden || - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - report?.participantAccountIDs?.includes(CONST.ACCOUNT_ID.NOTIFICATIONS) || (report?.participantAccountIDs?.length === 0 && !isChatThread(report) && !isPublicRoom(report) && @@ -6408,6 +6418,7 @@ export { isReportParticipant, isSelfDM, isSettled, + isSystemDM, isTaskReport, isThread, isThreadFirstChat, From 25adf3381f1d484e632baaefe0e60c076f7aa6ef Mon Sep 17 00:00:00 2001 From: Francois Laithier Date: Fri, 26 Apr 2024 18:17:54 -0700 Subject: [PATCH 2/2] Update default text in system chat --- src/components/ReportWelcomeText.tsx | 8 +++++++- src/languages/en.ts | 1 + src/languages/es.ts | 1 + src/libs/ReportUtils.ts | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/ReportWelcomeText.tsx b/src/components/ReportWelcomeText.tsx index d61bd5186ecc..339cd146c8cb 100644 --- a/src/components/ReportWelcomeText.tsx +++ b/src/components/ReportWelcomeText.tsx @@ -38,7 +38,8 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report); const isChatRoom = ReportUtils.isChatRoom(report); const isSelfDM = ReportUtils.isSelfDM(report); - const isDefault = !(isChatRoom || isPolicyExpenseChat || isSelfDM); + const isSystemDM = ReportUtils.isSystemDM(report); + const isDefault = !(isChatRoom || isPolicyExpenseChat || isSelfDM || isSystemDM); const participantAccountIDs = report?.participantAccountIDs ?? []; const isMultipleParticipant = participantAccountIDs.length > 1; const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(OptionsListUtils.getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails), isMultipleParticipant); @@ -133,6 +134,11 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP {translate('reportActionsView.beginningOfChatHistorySelfDM')} )} + {isSystemDM && ( + + {translate('reportActionsView.beginningOfChatHistorySystemDM')} + + )} {isDefault && ( {translate('reportActionsView.beginningOfChatHistory')} diff --git a/src/languages/en.ts b/src/languages/en.ts index 610603e227e7..bc9acb462d6f 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -509,6 +509,7 @@ export default { beginningOfChatHistoryPolicyExpenseChatPartTwo: ' and ', beginningOfChatHistoryPolicyExpenseChatPartThree: ' starts here! 🎉 This is the place to chat, submit expenses and settle up.', beginningOfChatHistorySelfDM: 'This is your personal space. Use it for notes, tasks, drafts, and reminders.', + beginningOfChatHistorySystemDM: "Welcome! Let's get you set up.", chatWithAccountManager: 'Chat with your account manager here', sayHello: 'Say hello!', yourSpace: 'Your space', diff --git a/src/languages/es.ts b/src/languages/es.ts index f9063fb560ac..ff1af7c8312f 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -502,6 +502,7 @@ export default { beginningOfChatHistoryPolicyExpenseChatPartTwo: ' y ', beginningOfChatHistoryPolicyExpenseChatPartThree: ' empieza aquí! 🎉 Este es el lugar donde chatear y presentar o pagar gastos.', beginningOfChatHistorySelfDM: 'Este es tu espacio personal. Úsalo para notas, tareas, borradores y recordatorios.', + beginningOfChatHistorySystemDM: "Welcome! Let's get you set up.", chatWithAccountManager: 'Chatea con tu gestor de cuenta aquí', sayHello: '¡Saluda!', yourSpace: 'Tu espacio', diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index f81520ac0e3b..fe2e2d8c27d0 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5202,7 +5202,7 @@ function isGroupChatAdmin(report: OnyxEntry, accountID: number) { */ function getMoneyRequestOptions(report: OnyxEntry, policy: OnyxEntry, reportParticipants: number[], canUseTrackExpense = true, filterDeprecatedTypes = false): IOUType[] { // In any thread or task report, we do not allow any new expenses yet - if (isChatThread(report) || isTaskReport(report) || (!canUseTrackExpense && isSelfDM(report))) { + if (isChatThread(report) || isTaskReport(report) || (!canUseTrackExpense && isSelfDM(report)) || isSystemDM(report)) { return []; }