Skip to content

Commit

Permalink
Allow system account chat to be listed in LHN, fix chat icons
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisl committed Apr 30, 2024
1 parent 0fc945b commit 1cbeb47
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/components/ReportWelcomeText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -142,6 +143,11 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP
<Text>{translate('reportActionsView.beginningOfChatHistorySelfDM')}</Text>
</Text>
)}
{isSystemDM && (
<Text>
<Text>{translate('reportActionsView.beginningOfChatHistorySystemDM')}</Text>
</Text>
)}
{isDefault && (
<Text>
<Text>{translate('reportActionsView.beginningOfChatHistory')}</Text>
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
12 changes: 9 additions & 3 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -3123,6 +3127,10 @@ function getReportName(report: OnyxEntry<Report>, policy: OnyxEntry<Policy> = nu
formattedName = getDisplayNameForParticipant(currentUserAccountID, undefined, undefined, true);
}

if (isSystemChat(report)) {
formattedName = getDisplayNameForParticipant(CONST.ACCOUNT_ID.NOTIFICATIONS);
}

if (isInvoiceRoom(report)) {
formattedName = getInvoicesChatName(report);
}
Expand Down Expand Up @@ -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) &&
Expand Down Expand Up @@ -5382,7 +5388,7 @@ function isGroupChatAdmin(report: OnyxEntry<Report>, accountID: number) {
*/
function getMoneyRequestOptions(report: OnyxEntry<Report>, policy: OnyxEntry<Policy>, 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 [];
}

Expand Down

0 comments on commit 1cbeb47

Please sign in to comment.