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
1 change: 0 additions & 1 deletion src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3180,7 +3180,6 @@ const CONST = {
CANCEL_PAYMENT: 'cancelPayment',
UNAPPROVE: 'unapprove',
DEBUG: 'debug',
GO_TO_WORKSPACE: 'goToWorkspace',
},
EDIT_REQUEST_FIELD: {
AMOUNT: 'amount',
Expand Down
57 changes: 20 additions & 37 deletions src/pages/ReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta
const shouldShowNotificationPref = !isMoneyRequestReport && ReportUtils.getReportNotificationPreference(report) !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN;
const shouldShowWriteCapability = !isMoneyRequestReport;
const shouldShowMenuItem = shouldShowNotificationPref || shouldShowWriteCapability || (!!report?.visibility && report.chatType !== CONST.REPORT.CHAT_TYPE.INVOICE);
const shouldShowGoToWorkspace = policy && policy.type !== CONST.POLICY.TYPE.PERSONAL && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;

const isPayer = ReportUtils.isPayer(session, moneyRequestReport);
const isSettled = ReportUtils.isSettled(moneyRequestReport?.reportID ?? '-1');
Expand Down Expand Up @@ -451,6 +450,23 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta
});
}

if (shouldShowLeaveButton) {
items.push({
key: CONST.REPORT_DETAILS_MENU_ITEM.LEAVE_ROOM,
translationKey: 'common.leave',
icon: Expensicons.Exit,
isAnonymousAction: true,
action: () => {
if (ReportUtils.getParticipantsAccountIDsForDisplay(report, false, true).length === 1 && isRootGroupChat) {
setIsLastMemberLeavingGroupModalVisible(true);
return;
}

leaveChat();
},
});
}

if (isMoneyRequestReport) {
items.push({
key: CONST.REPORT_DETAILS_MENU_ITEM.DOWNLOAD,
Expand Down Expand Up @@ -492,23 +508,6 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta
});
}

if (shouldShowGoToWorkspace) {
items.push({
key: CONST.REPORT_DETAILS_MENU_ITEM.GO_TO_WORKSPACE,
translationKey: 'workspace.common.goToWorkspace',
icon: Expensicons.Building,
action: () => {
if (isSmallScreenWidth) {
Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(report?.policyID ?? '-1'));
return;
}
Navigation.navigate(ROUTES.WORKSPACE_PROFILE.getRoute(report?.policyID ?? '-1'));
},
isAnonymousAction: false,
shouldShowRightIcon: true,
});
}

if (report?.reportID && isDebugModeEnabled) {
items.push({
key: CONST.REPORT_DETAILS_MENU_ITEM.DEBUG,
Expand All @@ -525,6 +524,7 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta
isSelfDM,
isArchivedRoom,
isGroupChat,
isRootGroupChat,
isDefaultRoom,
isChatThread,
isPolicyEmployee,
Expand All @@ -543,12 +543,14 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta
shouldShowMenuItem,
isTaskReport,
isCanceledTaskReport,
shouldShowLeaveButton,
activeChatMembers.length,
shouldOpenRoomMembersPage,
shouldShowCancelPaymentButton,
session,
isOffline,
transactionIDList,
leaveChat,
canUnapproveRequest,
isDebugModeEnabled,
unapproveExpenseReportOrShowModal,
Expand All @@ -560,8 +562,6 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta
parentReportAction,
moneyRequestReport?.reportID,
isDeletedParentAction,
isSmallScreenWidth,
shouldShowGoToWorkspace,
]);

const displayNamesWithTooltips = useMemo(() => {
Expand Down Expand Up @@ -920,23 +920,6 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta
/>
))}

{shouldShowLeaveButton && (
<MenuItem
key={CONST.REPORT_DETAILS_MENU_ITEM.LEAVE_ROOM}
icon={Expensicons.Exit}
title={translate('common.leave')}
isAnonymousAction
onPress={() => {
if (ReportUtils.getParticipantsAccountIDsForDisplay(report, false, true).length === 1 && isRootGroupChat) {
setIsLastMemberLeavingGroupModalVisible(true);
return;
}

leaveChat();
}}
/>
)}

{shouldShowDeleteButton && (
<MenuItem
key={CONST.REPORT_DETAILS_MENU_ITEM.DELETE}
Expand Down