From 0b66f05fd7e79510dc69f1afff721eefb146d554 Mon Sep 17 00:00:00 2001 From: Dysto coder Date: Tue, 21 Oct 2025 12:07:23 +0300 Subject: [PATCH 1/2] don't show admin room when it has a join request if it archived --- src/libs/ReportUtils.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index e2f6d503844f..b3c7f3212c64 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3841,13 +3841,6 @@ function getReasonAndReportActionThatRequiresAttention( const reportActions = getAllReportActions(optionOrReport.reportID); - if (isJoinRequestInAdminRoom(optionOrReport)) { - return { - reason: CONST.REQUIRES_ATTENTION_REASONS.HAS_JOIN_REQUEST, - reportAction: getActionableJoinRequestPendingReportAction(optionOrReport.reportID), - }; - } - if (hasUnresolvedCardFraudAlert(optionOrReport)) { return { reason: CONST.REQUIRES_ATTENTION_REASONS.HAS_UNRESOLVED_CARD_FRAUD_ALERT, @@ -3859,6 +3852,13 @@ function getReasonAndReportActionThatRequiresAttention( return null; } + if (isJoinRequestInAdminRoom(optionOrReport)) { + return { + reason: CONST.REQUIRES_ATTENTION_REASONS.HAS_JOIN_REQUEST, + reportAction: getActionableJoinRequestPendingReportAction(optionOrReport.reportID), + }; + } + if (isUnreadWithMention(optionOrReport)) { return { reason: CONST.REQUIRES_ATTENTION_REASONS.IS_UNREAD_WITH_MENTION, From 4e6996f8ca48a318ebe31d98aad1dfdf1dac9e7c Mon Sep 17 00:00:00 2001 From: Dysto coder Date: Tue, 21 Oct 2025 14:08:38 +0300 Subject: [PATCH 2/2] add a unit test --- tests/unit/ReportUtilsTest.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index c499d87ee929..8424ebb09775 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -111,6 +111,7 @@ import type { Transaction, } from '@src/types/onyx'; import type {ErrorFields, Errors} from '@src/types/onyx/OnyxCommon'; +import type {JoinWorkspaceResolution} from '@src/types/onyx/OriginalMessage'; import type {ACHAccount} from '@src/types/onyx/Policy'; import type {Participant, Participants} from '@src/types/onyx/Report'; import type {SearchTransaction} from '@src/types/onyx/SearchResults'; @@ -5772,6 +5773,28 @@ describe('ReportUtils', () => { const {result: isReportArchived} = renderHook(() => useReportIsArchived(report?.reportID)); const result = getReasonAndReportActionThatRequiresAttention(report, undefined, isReportArchived.current); + // Then the result is null + expect(result).toBe(null); + }); + it('should return null for an archived report when there is a policy pending join request', async () => { + // Given an archived admin room with a pending join request + const joinRequestReportAction: ReportAction = { + ...createRandomReportAction(50400), + originalMessage: { + choice: '' as JoinWorkspaceResolution, + policyID: '1', + }, + actionName: CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_JOIN_REQUEST, + }; + + const adminReport = createAdminRoom(34001); + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${adminReport.reportID}`, {[joinRequestReportAction.reportActionID]: joinRequestReportAction}); + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${adminReport.reportID}`, {private_isArchived: DateUtils.getDBTime()}); + + // When the reason is retrieved + const {result: isReportArchived} = renderHook(() => useReportIsArchived(adminReport?.reportID)); + const result = getReasonAndReportActionThatRequiresAttention(adminReport, undefined, isReportArchived.current); + // Then the result is null expect(result).toBe(null); });