diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ea11eced2b30..1ddb679573c8 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -7923,7 +7923,14 @@ function shouldDisableRename(report: OnyxEntry): boolean { * @param policy - the workspace the report is on, null if the user isn't a member of the workspace */ function canEditWriteCapability(report: OnyxEntry, policy: OnyxEntry): boolean { - return isPolicyAdminPolicyUtils(policy) && !isAdminRoom(report) && !isArchivedReport(getReportNameValuePairs(report?.reportID)) && !isThread(report) && !isInvoiceRoom(report); + return ( + isPolicyAdminPolicyUtils(policy) && + !isAdminRoom(report) && + !isArchivedReport(getReportNameValuePairs(report?.reportID)) && + !isThread(report) && + !isInvoiceRoom(report) && + !isPolicyExpenseChat(report) + ); } /** diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index 87184b1b982a..0e3fa356f343 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -9,6 +9,7 @@ import { buildOptimisticIOUReportAction, buildParticipantsFromAccountIDs, buildTransactionThread, + canEditWriteCapability, getAllAncestorReportActions, getApprovalChain, getChatByParticipants, @@ -1834,6 +1835,16 @@ describe('ReportUtils', () => { }); }); + describe('canEditWriteCapability', () => { + it('should return false for workspace chat', () => { + const workspaceChat: Report = { + ...createRandomReport(1), + chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, + }; + expect(canEditWriteCapability(workspaceChat, {...policy, role: CONST.POLICY.ROLE.ADMIN})).toBe(false); + }); + }); + describe('getApprovalChain', () => { describe('submit and close policy', () => { it('should return empty array', () => {