Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3858,13 +3858,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,
Expand All @@ -3876,6 +3869,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,
Expand Down
23 changes: 23 additions & 0 deletions tests/unit/ReportUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -5778,6 +5779,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);
});
Expand Down
Loading