diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index f50c1f860cbd..fe96f7df3a62 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -9315,7 +9315,12 @@ function isAdminOwnerApproverOrReportOwner(report: OnyxEntry, policy: On /** * Whether the user can join a report */ -function canJoinChat(report: OnyxEntry, parentReportAction: OnyxInputOrEntry, policy: OnyxInputOrEntry): boolean { +function canJoinChat( + report: OnyxEntry, + parentReportAction: OnyxInputOrEntry, + policy: OnyxInputOrEntry, + reportNameValuePairs: ReportNameValuePairs | undefined, +): boolean { // We disabled thread functions for whisper action // So we should not show join option for existing thread on whisper message that has already been left, or manually leave it if (isWhisperAction(parentReportAction)) { @@ -9338,6 +9343,10 @@ function canJoinChat(report: OnyxEntry, parentReportAction: OnyxInputOrE return false; } + if (isArchivedReport(reportNameValuePairs)) { + return false; + } + return isChatThread(report) || isUserCreatedPolicyRoom(report) || isNonAdminOrOwnerOfPolicyExpenseChat(report, policy); } diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index e256df539157..4f1eb1dc48ee 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -779,7 +779,7 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta caseID !== CASES.DEFAULT && (canHoldUnholdReportAction.canHoldRequest || canHoldUnholdReportAction.canUnholdRequest) && !isArchivedNonExpenseReport(transactionThreadReportID ? report : parentReport, transactionThreadReportID ? reportNameValuePairs : parentReportNameValuePairs); - const canJoin = canJoinChat(report, parentReportAction, policy); + const canJoin = canJoinChat(report, parentReportAction, policy, reportNameValuePairs); const promotedActions = useMemo(() => { const result: PromotedAction[] = []; diff --git a/src/pages/home/HeaderView.tsx b/src/pages/home/HeaderView.tsx index c498dca5e1fb..feb2a6cbfbae 100644 --- a/src/pages/home/HeaderView.tsx +++ b/src/pages/home/HeaderView.tsx @@ -168,7 +168,7 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked, const join = callFunctionIfActionIsAllowed(() => joinRoom(report)); - const canJoin = canJoinChat(report, parentReportAction, policy); + const canJoin = canJoinChat(report, parentReportAction, policy, reportNameValuePairs); const joinButton = (