Skip to content

Commit

Permalink
Merge pull request Expensify#48222 from FitseTLT/fix-admin-label-adde…
Browse files Browse the repository at this point in the history
…d-optimistically-in-policy-rooms

Fix - Remove Optimistically added admin role on policy chat reports
  • Loading branch information
deetergp authored Aug 30, 2024
2 parents a37a613 + 66ab027 commit d71e95b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/actions/PolicyTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit d71e95b

Please sign in to comment.