Skip to content

Commit 46df47f

Browse files
authored
Merge pull request #61045 from thelullabyy/fix/60529-archived-room-still-show-button-join
Room - Archived room still displays the "Join" option when opened
2 parents 884ba29 + d15ce3c commit 46df47f

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/libs/ReportUtils.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -9327,7 +9327,12 @@ function isAdminOwnerApproverOrReportOwner(report: OnyxEntry<Report>, policy: On
93279327
/**
93289328
* Whether the user can join a report
93299329
*/
9330-
function canJoinChat(report: OnyxEntry<Report>, parentReportAction: OnyxInputOrEntry<ReportAction>, policy: OnyxInputOrEntry<Policy>): boolean {
9330+
function canJoinChat(
9331+
report: OnyxEntry<Report>,
9332+
parentReportAction: OnyxInputOrEntry<ReportAction>,
9333+
policy: OnyxInputOrEntry<Policy>,
9334+
reportNameValuePairs: ReportNameValuePairs | undefined,
9335+
): boolean {
93319336
// We disabled thread functions for whisper action
93329337
// So we should not show join option for existing thread on whisper message that has already been left, or manually leave it
93339338
if (isWhisperAction(parentReportAction)) {
@@ -9350,6 +9355,10 @@ function canJoinChat(report: OnyxEntry<Report>, parentReportAction: OnyxInputOrE
93509355
return false;
93519356
}
93529357

9358+
if (isArchivedReport(reportNameValuePairs)) {
9359+
return false;
9360+
}
9361+
93539362
return isChatThread(report) || isUserCreatedPolicyRoom(report) || isNonAdminOrOwnerOfPolicyExpenseChat(report, policy);
93549363
}
93559364

src/pages/ReportDetailsPage.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta
779779
caseID !== CASES.DEFAULT &&
780780
(canHoldUnholdReportAction.canHoldRequest || canHoldUnholdReportAction.canUnholdRequest) &&
781781
!isArchivedNonExpenseReport(transactionThreadReportID ? report : parentReport, transactionThreadReportID ? reportNameValuePairs : parentReportNameValuePairs);
782-
const canJoin = canJoinChat(report, parentReportAction, policy);
782+
const canJoin = canJoinChat(report, parentReportAction, policy, reportNameValuePairs);
783783

784784
const promotedActions = useMemo(() => {
785785
const result: PromotedAction[] = [];

src/pages/home/HeaderView.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked,
172172

173173
const join = callFunctionIfActionIsAllowed(() => joinRoom(report));
174174

175-
const canJoin = canJoinChat(report, parentReportAction, policy);
175+
const canJoin = canJoinChat(report, parentReportAction, policy, reportNameValuePairs);
176176

177177
const joinButton = (
178178
<Button

0 commit comments

Comments
 (0)