diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 129c44767b18..f11ab21a053c 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; shouldSeparateWorkspaceChat?: boolean; shouldSeparateSelfDMChat?: boolean; @@ -1273,6 +1274,7 @@ function getValidReports(reports: OptionList['reports'], config: GetValidReports includeThreads = false, includeTasks = false, includeMoneyRequests = false, + includeReadOnly = true, transactionViolations = {}, includeSelfDM = false, includeInvoiceRooms = false, @@ -1348,6 +1350,10 @@ function getValidReports(reports: OptionList['reports'], config: 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; @@ -1597,6 +1603,7 @@ function getShareLogOptions(options: OptionList, betas: Beta[] = []): Options { includeOwnedWorkspaceChats: true, includeSelfDM: true, includeThreads: true, + includeReadOnly: false, }); } 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, []);