): boolean { - return isPolicyAdminPolicyUtils(policy); -} - function getReportActionWithSmartscanError(reportActions: ReportAction[]): ReportAction | undefined { return reportActions.find((action) => { const isReportPreview = isReportPreviewAction(action); @@ -11854,7 +11850,6 @@ export { canEditReportPolicy, canEditFieldOfMoneyRequest, canEditMoneyRequest, - canEditPolicyDescription, canEditReportAction, canEditReportDescription, canEditRoomVisibility, diff --git a/tests/unit/ReportPrimaryActionUtilsTest.ts b/tests/unit/ReportPrimaryActionUtilsTest.ts index d6af40ef424c..e73dcb25aceb 100644 --- a/tests/unit/ReportPrimaryActionUtilsTest.ts +++ b/tests/unit/ReportPrimaryActionUtilsTest.ts @@ -44,7 +44,7 @@ describe('getPrimaryAction', () => { await Onyx.set(ONYXKEYS.PERSONAL_DETAILS_LIST, {[CURRENT_USER_ACCOUNT_ID]: PERSONAL_DETAILS}); }); - it('should return ADD_EXPENSE for expense report with no transactions', async () => { + it('should return empty string for expense report with no transactions', async () => { const report = { reportID: REPORT_ID, type: CONST.REPORT.TYPE.EXPENSE, @@ -53,10 +53,7 @@ describe('getPrimaryAction', () => { statusNum: CONST.REPORT.STATUS_NUM.OPEN, } as unknown as Report; await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, report); - - expect(getReportPrimaryAction({report, chatReport, reportTransactions: [], violations: {}, policy: {} as Policy, isChatReportArchived: false})).toBe( - CONST.REPORT.PRIMARY_ACTIONS.ADD_EXPENSE, - ); + expect(getReportPrimaryAction({report, chatReport, reportTransactions: [], violations: {}, policy: {} as Policy, isChatReportArchived: false})).toBe(''); }); it('should return SUBMIT for expense report with manual submit', async () => { diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index 2a813f18a2e4..0baa7b8f5380 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -5233,6 +5233,22 @@ describe('ReportUtils', () => { // Then the result is false expect(result).toBe(false); }); + + it('should return false for a closed report', async () => { + // Given a closed expense report + const report: Report = { + ...createRandomReport(10002), + type: CONST.REPORT.TYPE.EXPENSE, + statusNum: CONST.REPORT.STATUS_NUM.CLOSED, + }; + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, report); + + const {result: isReportArchived} = renderHook(() => useReportIsArchived(report?.reportID)); + const result = canAddTransaction(report, isReportArchived.current); + + // Then the result is false + expect(result).toBe(false); + }); }); describe('canDeleteTransaction', () => { @@ -5270,6 +5286,22 @@ describe('ReportUtils', () => { expect(result).toBe(false); }); + it('should return false for a closed report', async () => { + // Given a closed expense report + const report: Report = { + ...createRandomReport(10002), + type: CONST.REPORT.TYPE.EXPENSE, + statusNum: CONST.REPORT.STATUS_NUM.CLOSED, + }; + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, report); + + const {result: isReportArchived} = renderHook(() => useReportIsArchived(report?.reportID)); + const result = canAddTransaction(report, isReportArchived.current); + + // Then the result is false + expect(result).toBe(false); + }); + describe('with workflow disabled', () => { const workflowDisabledPolicy: Policy = { ...createRandomPolicy(1),