From 140943dd7048167b64c7bfb24b339e6bcb29f1e3 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Wed, 5 Feb 2025 15:23:55 +0800 Subject: [PATCH 1/2] filter out read only report --- src/libs/OptionsListUtils.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 7ba5ffd0c99b..0a37cf540f20 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -194,6 +194,7 @@ type GetValidReportsConfig = { includeMoneyRequests?: boolean; includeInvoiceRooms?: boolean; includeDomainEmail?: boolean; + includeReadOnly?: boolean; loginsToExclude?: Record; } & GetValidOptionsSharedConfig; @@ -1257,6 +1258,7 @@ function getValidReports( includeThreads = false, includeTasks = false, includeMoneyRequests = false, + includeReadOnly = true, transactionViolations = {}, includeSelfDM = false, includeInvoiceRooms = false, @@ -1329,6 +1331,10 @@ function getValidReports( continue; } + if (!canUserPerformWriteAction(report) && !includeReadOnly) { + continue; + } + // In case user needs to add credit bank account, don't allow them to submit an expense from the workspace. if (includeOwnedWorkspaceChats && hasIOUWaitingOnCurrentUserBankAccount(report)) { continue; @@ -1577,6 +1583,7 @@ function getShareLogOptions(options: OptionList, betas: Beta[] = []): Options { includeOwnedWorkspaceChats: true, includeSelfDM: true, includeThreads: true, + includeReadOnly: false, }); } From 09d06bd4e5e031e267ebf943676ac08f4ddeed06 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 7 Feb 2025 11:18:02 +0800 Subject: [PATCH 2/2] add unit test --- tests/unit/OptionsListUtilsTest.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/unit/OptionsListUtilsTest.ts b/tests/unit/OptionsListUtilsTest.ts index 8c3618bf695c..b3008f0f2f1b 100644 --- a/tests/unit/OptionsListUtilsTest.ts +++ b/tests/unit/OptionsListUtilsTest.ts @@ -735,6 +735,20 @@ describe('OptionsListUtils', () => { expect(results.recentReports.length).toBe(Object.values(OPTIONS_WITH_WORKSPACE_ROOM.reports).length - 1); }); + describe('getShareLogOptions', () => { + it('should not include read-only report', () => { + // Given a list of 11 report options with reportID of 10 is archived + // OPTIONS, defined above + + // When getting the share log options + const results = OptionsListUtils.getShareLogOptions(OPTIONS, []); + + // Then the report with reportID of 10 should not be included on the list + expect(results.recentReports.length).toBe(10); + expect(results.recentReports.find((report) => report.reportID === '10')).toBeUndefined(); + }); + }); + it('getMemberInviteOptions()', () => { // When we only pass personal details const results = OptionsListUtils.getMemberInviteOptions(OPTIONS.personalDetails, []);