diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index f8f85beff4ad..e3cc0e224c55 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4975,6 +4975,10 @@ function buildOptimisticTaskReportAction( }; } +function isWorkspaceChat(chatType: string) { + return chatType === CONST.REPORT.CHAT_TYPE.POLICY_ADMINS || chatType === CONST.REPORT.CHAT_TYPE.POLICY_ANNOUNCE || chatType === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT; +} + /** * Builds an optimistic chat report with a randomly generated reportID and as much information as we currently have */ @@ -4996,10 +5000,11 @@ function buildOptimisticChatReport( optimisticReportID = '', shouldShowParticipants = true, ): OptimisticChatReport { + const isWorkspaceChatType = chatType && isWorkspaceChat(chatType); const participants = participantList.reduce((reportParticipants: Participants, accountID: number) => { const participant: ReportParticipant = { hidden: !shouldShowParticipants, - role: accountID === currentUserAccountID ? CONST.REPORT.ROLE.ADMIN : CONST.REPORT.ROLE.MEMBER, + ...(!isWorkspaceChatType && {role: accountID === currentUserAccountID ? CONST.REPORT.ROLE.ADMIN : CONST.REPORT.ROLE.MEMBER}), }; // eslint-disable-next-line no-param-reassign reportParticipants[accountID] = participant; diff --git a/tests/actions/PolicyTest.ts b/tests/actions/PolicyTest.ts index 5b95d50eed52..a9af7b9da7d8 100644 --- a/tests/actions/PolicyTest.ts +++ b/tests/actions/PolicyTest.ts @@ -12,7 +12,7 @@ import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; const ESH_EMAIL = 'eshgupta1217@gmail.com'; const ESH_ACCOUNT_ID = 1; -const ESH_PARTICIPANT: Participant = {hidden: false, role: 'admin'}; +const ESH_PARTICIPANT: Participant = {hidden: false}; const WORKSPACE_NAME = "Esh's Workspace"; OnyxUpdateManager();