Skip to content

Room - Archived room still displays the "Join" option when opened #61045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
11 changes: 10 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9315,7 +9315,12 @@ function isAdminOwnerApproverOrReportOwner(report: OnyxEntry<Report>, policy: On
/**
* Whether the user can join a report
*/
function canJoinChat(report: OnyxEntry<Report>, parentReportAction: OnyxInputOrEntry<ReportAction>, policy: OnyxInputOrEntry<Policy>): boolean {
function canJoinChat(
report: OnyxEntry<Report>,
parentReportAction: OnyxInputOrEntry<ReportAction>,
policy: OnyxInputOrEntry<Policy>,
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)) {
Expand All @@ -9338,6 +9343,10 @@ function canJoinChat(report: OnyxEntry<Report>, parentReportAction: OnyxInputOrE
return false;
}

if (isArchivedReport(reportNameValuePairs)) {
return false;
}

return isChatThread(report) || isUserCreatedPolicyRoom(report) || isNonAdminOrOwnerOfPolicyExpenseChat(report, policy);
}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/ReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [];
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/HeaderView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
<Button
Expand Down