From e27237dd1067da46f9d998148a1e11ed8f0ec620 Mon Sep 17 00:00:00 2001 From: HezekielT Date: Wed, 14 Aug 2024 13:30:14 +0300 Subject: [PATCH 1/5] check for auditor permission --- src/libs/ReportUtils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index a0d2e9780411..db23226b4251 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1397,8 +1397,9 @@ function isJoinRequestInAdminRoom(report: OnyxEntry): boolean { * Checks if the user can write in the provided report */ function canWriteInReport(report: OnyxEntry): boolean { + if (Array.isArray(report?.permissions) && report?.permissions.length > 0) { - return report?.permissions?.includes(CONST.REPORT.PERMISSIONS.WRITE); + return report?.permissions?.includes(CONST.REPORT.PERMISSIONS.WRITE) || (report?.permissions?.includes(CONST.REPORT.PERMISSIONS.AUDITOR) && report?.type === 'expense'); } return true; From 1ecaefa4bb1f407a5e7a5c2f1809b75d83322fed Mon Sep 17 00:00:00 2001 From: HezekielT Date: Wed, 14 Aug 2024 13:31:02 +0300 Subject: [PATCH 2/5] add AUDITOR to CONST --- src/CONST.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CONST.ts b/src/CONST.ts index b61a97eb3289..67eb686f0db0 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -911,6 +911,7 @@ const CONST = { WRITE: 'write', SHARE: 'share', OWN: 'own', + AUDITOR: 'auditor' }, INVOICE_RECEIVER_TYPE: { INDIVIDUAL: 'individual', From 956b8b07449dd968f6aa555ca01b36315eac33b4 Mon Sep 17 00:00:00 2001 From: HezekielT Date: Wed, 14 Aug 2024 13:32:49 +0300 Subject: [PATCH 3/5] run prettier --- src/CONST.ts | 2 +- src/libs/ReportUtils.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 67eb686f0db0..a3f17aa03b49 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -911,7 +911,7 @@ const CONST = { WRITE: 'write', SHARE: 'share', OWN: 'own', - AUDITOR: 'auditor' + AUDITOR: 'auditor', }, INVOICE_RECEIVER_TYPE: { INDIVIDUAL: 'individual', diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index db23226b4251..7b54cd6af765 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1397,7 +1397,6 @@ function isJoinRequestInAdminRoom(report: OnyxEntry): boolean { * Checks if the user can write in the provided report */ function canWriteInReport(report: OnyxEntry): boolean { - if (Array.isArray(report?.permissions) && report?.permissions.length > 0) { return report?.permissions?.includes(CONST.REPORT.PERMISSIONS.WRITE) || (report?.permissions?.includes(CONST.REPORT.PERMISSIONS.AUDITOR) && report?.type === 'expense'); } From 46a0329324d5dae59bcafc7c9a93307565845b16 Mon Sep 17 00:00:00 2001 From: HezekielT Date: Wed, 14 Aug 2024 15:04:49 +0300 Subject: [PATCH 4/5] used CONST for EXPENSE --- src/libs/ReportUtils.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 7b54cd6af765..36afdc9755bb 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1398,7 +1398,9 @@ function isJoinRequestInAdminRoom(report: OnyxEntry): boolean { */ function canWriteInReport(report: OnyxEntry): boolean { if (Array.isArray(report?.permissions) && report?.permissions.length > 0) { - return report?.permissions?.includes(CONST.REPORT.PERMISSIONS.WRITE) || (report?.permissions?.includes(CONST.REPORT.PERMISSIONS.AUDITOR) && report?.type === 'expense'); + return ( + report?.permissions?.includes(CONST.REPORT.PERMISSIONS.WRITE) || (report?.permissions?.includes(CONST.REPORT.PERMISSIONS.AUDITOR) && report?.type === CONST.REPORT.TYPE.EXPENSE) + ); } return true; From c2775b5c0e1e7b5fabe1a6017f3c02274a993d36 Mon Sep 17 00:00:00 2001 From: HezekielT Date: Thu, 15 Aug 2024 12:55:56 +0300 Subject: [PATCH 5/5] used isExpenseReport() --- src/libs/ReportUtils.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 36afdc9755bb..68f69dc4e653 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1398,9 +1398,7 @@ function isJoinRequestInAdminRoom(report: OnyxEntry): boolean { */ function canWriteInReport(report: OnyxEntry): boolean { if (Array.isArray(report?.permissions) && report?.permissions.length > 0) { - return ( - report?.permissions?.includes(CONST.REPORT.PERMISSIONS.WRITE) || (report?.permissions?.includes(CONST.REPORT.PERMISSIONS.AUDITOR) && report?.type === CONST.REPORT.TYPE.EXPENSE) - ); + return report?.permissions?.includes(CONST.REPORT.PERMISSIONS.WRITE) || (report?.permissions?.includes(CONST.REPORT.PERMISSIONS.AUDITOR) && isExpenseReport(report)); } return true;