Skip to content

Commit

Permalink
Update conditions for leave button
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhenjaHorbach committed May 15, 2024
1 parent d1814c1 commit 7c630c8
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/pages/ReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
const chatRoomSubtitle = useMemo(() => ReportUtils.getChatRoomSubtitle(report), [report, policy]);
const parentNavigationSubtitleData = ReportUtils.getParentNavigationSubtitle(report);
const isGroupChat = useMemo(() => ReportUtils.isGroupChat(report), [report]);
const isRootGroupChat = useMemo(() => ReportUtils.isRootGroupChat(report), [report]);
const isThread = useMemo(() => ReportUtils.isThread(report), [report]);
const participants = useMemo(() => {
if (isGroupChat) {
Expand Down Expand Up @@ -197,15 +196,15 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
});
}

if (isGroupChat || (isChatRoom && ReportUtils.canLeaveChat(report, policy ?? null))) {
if ((isGroupChat || (isChatRoom && ReportUtils.canLeaveChat(report, policy ?? null))) && !isThread) {
items.push({
key: CONST.REPORT_DETAILS_MENU_ITEM.LEAVE_ROOM,
translationKey: 'common.leave',
icon: Expensicons.Exit,
isAnonymousAction: true,
shouldShowRightIcon: false,
action: () => {
if (Object.keys(report?.participants ?? {}).length === 1 && isRootGroupChat) {
if (Object.keys(report?.participants ?? {}).length === 1 && isGroupChat) {
setIsLastMemberLeavingGroupModalVisible(true);
return;
}
Expand All @@ -229,11 +228,11 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
isPolicyExpenseChat,
isMoneyRequestReport,
isInvoiceReport,
isThread,
isChatRoom,
policy,
activeChatMembers.length,
session,
isRootGroupChat,
leaveChat,
]);

Expand Down Expand Up @@ -281,10 +280,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
/>
);

const reportName =
ReportUtils.isDeprecatedGroupDM(report) || ReportUtils.isGroupChat(report)
? ReportUtils.getGroupChatName(undefined, false, report.reportID ?? '')
: ReportUtils.getReportName(report);
const reportName = ReportUtils.isDeprecatedGroupDM(report) || isGroupChat ? ReportUtils.getGroupChatName(undefined, false, report.reportID ?? '') : ReportUtils.getReportName(report);
return (
<ScreenWrapper testID={ReportDetailsPage.displayName}>
<FullPageNotFoundView shouldShow={isEmptyObject(report)}>
Expand Down

0 comments on commit 7c630c8

Please sign in to comment.