Skip to content
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

Allow accessing the members page in a thread #34993

Merged
merged 21 commits into from
Mar 12, 2024
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
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB: these conditions are super confusing and I'd be surprised if somebody doesn't break these eventually. No idea how to simplify things, but something we should consider in case we have to revisit this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree, I was thinking of ways to simplify them but that would involve touching a bunch of other flows, so I elected to keep them the same for now so we could get them out sooner.

) {
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
Loading