Skip to content

Commit

Permalink
Merge pull request #34993 from Expensify/jasper-allowInvitesInThreads…
Browse files Browse the repository at this point in the history
…InDMs

Allow accessing the members page in a thread
  • Loading branch information
srikarparsi authored Mar 12, 2024
2 parents ffb9933 + c4ee5d3 commit 92bbd8b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
26 changes: 18 additions & 8 deletions src/pages/ReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
const isPolicyMember = useMemo(() => PolicyUtils.isPolicyMember(report?.policyID ?? '', policies), [report?.policyID, policies]);
const shouldUseFullTitle = useMemo(() => ReportUtils.shouldUseFullTitleToDisplay(report), [report]);
const isChatRoom = useMemo(() => ReportUtils.isChatRoom(report), [report]);
const isThread = useMemo(() => ReportUtils.isChatThread(report), [report]);
const isUserCreatedPolicyRoom = useMemo(() => ReportUtils.isUserCreatedPolicyRoom(report), [report]);
const isDefaultRoom = useMemo(() => ReportUtils.isDefaultRoom(report), [report]);
const isChatThread = useMemo(() => ReportUtils.isChatThread(report), [report]);
const isArchivedRoom = useMemo(() => ReportUtils.isArchivedRoom(report), [report]);
const isMoneyRequestReport = useMemo(() => ReportUtils.isMoneyRequestReport(report), [report]);
const canEditReportDescription = useMemo(() => ReportUtils.canEditReportDescription(report, policy), [report, policy]);
Expand Down Expand Up @@ -117,24 +118,33 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
}

// The Members page is only shown when:
// - The report is a thread in a chat report
// - The report is not a user created room with participants to show i.e. DM, Group Chat, etc
// - The report is a user created room and the room and the current user is a workspace member i.e. non-workspace members should not see this option.
if ((!isUserCreatedPolicyRoom && participants.length) || (isUserCreatedPolicyRoom && isPolicyMember)) {
if (
((isDefaultRoom && isChatThread && isPolicyMember) ||
(!isUserCreatedPolicyRoom && participants.length) ||
(isUserCreatedPolicyRoom && (isPolicyMember || (isChatThread && !ReportUtils.isPublicRoom(report))))) &&
!ReportUtils.isConciergeChatReport(report)
) {
items.push({
key: CONST.REPORT_DETAILS_MENU_ITEM.MEMBERS,
translationKey: 'common.members',
icon: Expensicons.Users,
subtitle: participants.length,
isAnonymousAction: false,
action: () => {
if (isUserCreatedPolicyRoom && !report?.parentReportID) {
if (isUserCreatedPolicyRoom || isChatThread) {
Navigation.navigate(ROUTES.ROOM_MEMBERS.getRoute(report?.reportID ?? ''));
} else {
Navigation.navigate(ROUTES.REPORT_PARTICIPANTS.getRoute(report?.reportID ?? ''));
}
},
});
} else if (isUserCreatedPolicyRoom && (!participants.length || !isPolicyMember) && !report?.parentReportID) {
} else if (
(isUserCreatedPolicyRoom && (!participants.length || !isPolicyMember)) ||
((isDefaultRoom || ReportUtils.isPolicyExpenseChat(report)) && isChatThread && !isPolicyMember)
) {
items.push({
key: CONST.REPORT_DETAILS_MENU_ITEM.INVITE,
translationKey: 'common.invite',
Expand All @@ -157,7 +167,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
});

// Prevent displaying private notes option for threads and task reports
if (!isThread && !isMoneyRequestReport && !ReportUtils.isTaskReport(report)) {
if (!isChatThread && !isMoneyRequestReport && !ReportUtils.isTaskReport(report)) {
items.push({
key: CONST.REPORT_DETAILS_MENU_ITEM.PRIVATE_NOTES,
translationKey: 'privateNotes.title',
Expand All @@ -169,7 +179,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
}

return items;
}, [isArchivedRoom, participants.length, isThread, isMoneyRequestReport, report, isGroupDMChat, isPolicyMember, isUserCreatedPolicyRoom, session, isSelfDM]);
}, [isArchivedRoom, participants.length, isChatThread, isMoneyRequestReport, report, isGroupDMChat, isPolicyMember, isUserCreatedPolicyRoom, session, isSelfDM, isDefaultRoom]);

const displayNamesWithTooltips = useMemo(() => {
const hasMultipleParticipants = participants.length > 1;
Expand Down Expand Up @@ -217,8 +227,8 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
fullTitle={ReportUtils.getReportName(report)}
displayNamesWithTooltips={displayNamesWithTooltips}
tooltipEnabled
numberOfLines={isChatRoom && !isThread ? 0 : 1}
textStyles={[styles.textHeadline, styles.textAlignCenter, isChatRoom && !isThread ? undefined : styles.pre]}
numberOfLines={isChatRoom && !isChatThread ? 0 : 1}
textStyles={[styles.textHeadline, styles.textAlignCenter, isChatRoom && !isChatThread ? undefined : styles.pre]}
shouldUseFullTitle={shouldUseFullTitle}
/>
</View>
Expand Down
4 changes: 3 additions & 1 deletion src/pages/RoomMembersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ function RoomMembersPage({report, session, policies}: RoomMembersPageProps) {
testID={RoomMembersPage.displayName}
>
<FullPageNotFoundView
shouldShow={isEmptyObject(report) || !isPolicyMember}
shouldShow={
isEmptyObject(report) || (!ReportUtils.isChatThread(report) && ((ReportUtils.isUserCreatedPolicyRoom(report) && !isPolicyMember) || ReportUtils.isDefaultRoom(report)))
}
subtitleKey={isEmptyObject(report) ? undefined : 'roomMembersPage.notAuthorized'}
onBackButtonPress={() => {
Navigation.goBack(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID));
Expand Down

0 comments on commit 92bbd8b

Please sign in to comment.