From 1cbeb47110a45fe75b3df7b6c1f6d0d32cc72477 Mon Sep 17 00:00:00 2001 From: Francois Laithier Date: Mon, 29 Apr 2024 18:08:47 -0700 Subject: [PATCH] Allow system account chat to be listed in LHN, fix chat icons --- src/components/ReportWelcomeText.tsx | 8 +++++++- src/languages/en.ts | 1 + src/languages/es.ts | 1 + src/libs/ReportUtils.ts | 12 +++++++++--- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/components/ReportWelcomeText.tsx b/src/components/ReportWelcomeText.tsx index 5b2ba1720ab0..6ac5b16374ff 100644 --- a/src/components/ReportWelcomeText.tsx +++ b/src/components/ReportWelcomeText.tsx @@ -40,7 +40,8 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP const isChatRoom = ReportUtils.isChatRoom(report); const isSelfDM = ReportUtils.isSelfDM(report); const isInvoiceRoom = ReportUtils.isInvoiceRoom(report); - const isDefault = !(isChatRoom || isPolicyExpenseChat || isSelfDM || isInvoiceRoom); + const isSystemDM = ReportUtils.isSystemChat(report); + const isDefault = !(isChatRoom || isPolicyExpenseChat || isSelfDM || isInvoiceRoom || isSystemDM); const participantAccountIDs = report?.participantAccountIDs ?? []; const isMultipleParticipant = participantAccountIDs.length > 1; const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(OptionsListUtils.getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails), isMultipleParticipant); @@ -142,6 +143,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 df70e836d04c..961904cdd047 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -511,6 +511,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 e86b50e74c62..94d23a62b8c2 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -504,6 +504,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 038357c86cbc..d4e73ae850bd 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1972,6 +1972,10 @@ function getIcons( return getIconsForParticipants([currentUserAccountID ?? 0], personalDetails); } + if (isSystemChat(report)) { + return getIconsForParticipants([CONST.ACCOUNT_ID.NOTIFICATIONS ?? 0], personalDetails); + } + if (isGroupChat(report)) { const groupChatIcon = { // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing @@ -3123,6 +3127,10 @@ function getReportName(report: OnyxEntry, policy: OnyxEntry = nu formattedName = getDisplayNameForParticipant(currentUserAccountID, undefined, undefined, true); } + if (isSystemChat(report)) { + formattedName = getDisplayNameForParticipant(CONST.ACCOUNT_ID.NOTIFICATIONS); + } + if (isInvoiceRoom(report)) { formattedName = getInvoicesChatName(report); } @@ -4973,8 +4981,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) && @@ -5382,7 +5388,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)) || isInvoiceRoom(report) || isInvoiceReport(report)) { + if (isChatThread(report) || isTaskReport(report) || (!canUseTrackExpense && isSelfDM(report)) || isInvoiceRoom(report) || isInvoiceReport(report) || isSystemChat(report)) { return []; }