Repository navigation
"Group/room name" field out of Settings and into Report #40858
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
Changes from all commits
a3df517
2dfbf0a
d6c3d73
8820119
0fd8837
48344f4
e388d47
cda911d
940270c
e43214c
62e1b95
197d7c5
38b582e
23b526e
dc45908
84e6618
2e4c24f
ed809e8
41300db
1880e35
1750b3d
c149e06
b628b52
0f1c733
ae6d382
a1ff130
4f6b853
f08a68e
62838ac
018898d
5d0f955
c44ae09
14cadc4
9d1b640
f63daad
effab38
2a43c99
9311622
47bc342
4bec870
fc361d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -72,22 +72,34 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD | |||
| const isPolicyAdmin = useMemo(() => PolicyUtils.isPolicyAdmin(policy ?? null), [policy]); | ||||
| const isPolicyEmployee = useMemo(() => PolicyUtils.isPolicyEmployee(report?.policyID ?? '', policies), [report?.policyID, policies]); | ||||
| const isPolicyExpenseChat = useMemo(() => ReportUtils.isPolicyExpenseChat(report), [report]); | ||||
|
|
||||
| const shouldUseFullTitle = useMemo(() => ReportUtils.shouldUseFullTitleToDisplay(report), [report]); | ||||
| const isChatRoom = useMemo(() => ReportUtils.isChatRoom(report), [report]); | ||||
| const isTaskReport = useMemo(() => ReportUtils.isTaskReport(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 isMoneyRequest = useMemo(() => ReportUtils.isMoneyRequest(report), [report]); | ||||
| const isInvoiceReport = useMemo(() => ReportUtils.isInvoiceReport(report), [report]); | ||||
| const isTaskReport = useMemo(() => ReportUtils.isTaskReport(report), [report]); | ||||
| const isInvoiceRoom = useMemo(() => ReportUtils.isInvoiceRoom(report), [report]); | ||||
| const canEditReportDescription = useMemo(() => ReportUtils.canEditReportDescription(report, policy), [report, policy]); | ||||
| const shouldShowReportDescription = isChatRoom && (canEditReportDescription || report.description !== ''); | ||||
|
|
||||
| const linkedWorkspace = useMemo(() => Object.values(policies ?? {}).find((linkedPolicy) => linkedPolicy && linkedPolicy.id === report?.policyID) ?? null, [policies, report?.policyID]); | ||||
|
marcaaron marked this conversation as resolved.
|
||||
| const shouldDisableRename = useMemo(() => ReportUtils.shouldDisableRename(report, linkedWorkspace), [report, linkedWorkspace]); | ||||
| const isDeprecatedGroupDM = useMemo(() => ReportUtils.isDeprecatedGroupDM(report), [report]); | ||||
| const parentNavigationSubtitleData = ReportUtils.getParentNavigationSubtitle(report); | ||||
| const shouldShowRoomName = | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're changing const shouldShowRoomName = !ReportUtils.isPolicyExpenseChat(report) && !ReportUtils.isChatThread(report) && !ReportUtils.isInvoiceRoom(report);to const shouldShowRoomName =
!ReportUtils.isChatThread(report) &&
!isDeprecatedGroupDM &&
!isPolicyExpenseChat &&
!isTaskReport &&
!isMoneyRequestReport &&
!isInvoiceRoom &&
!(isMoneyRequestReport || isInvoiceReport || isMoneyRequest);I agree we should confirm this behavior on Slack (and implement it inside of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
and I added the new behavior we needed. I don't think it needs to be a utility, because it's used just once on the About the last discussion, #40858 (comment)
Can you please explain what behavior you mean? Those new adjustments we already discussed it starting from this comment #40858 (comment) so I think the new behavior of the shouldShowRoomName is already approved. What do you think?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dragnoir, thank you! Missed the summary of changes in #40858 (comment), we should probably include it in the issue details |
||||
| !ReportUtils.isChatThread(report) && | ||||
| !isDeprecatedGroupDM && | ||||
| !isPolicyExpenseChat && | ||||
| !isTaskReport && | ||||
| !isMoneyRequestReport && | ||||
| !isInvoiceRoom && | ||||
| !(isMoneyRequestReport || isInvoiceReport || isMoneyRequest); | ||||
| // eslint-disable-next-line react-hooks/exhaustive-deps -- policy is a dependency because `getChatRoomSubtitle` calls `getPolicyName` which in turn retrieves the value from the `policy` value stored in Onyx | ||||
| const chatRoomSubtitle = useMemo(() => ReportUtils.getChatRoomSubtitle(report), [report, policy]); | ||||
| const parentNavigationSubtitleData = ReportUtils.getParentNavigationSubtitle(report); | ||||
| const isSystemChat = useMemo(() => ReportUtils.isSystemChat(report), [report]); | ||||
| const isGroupChat = useMemo(() => ReportUtils.isGroupChat(report), [report]); | ||||
| const isThread = useMemo(() => ReportUtils.isThread(report), [report]); | ||||
|
|
@@ -99,17 +111,13 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD | |||
|
|
||||
| return ReportUtils.getVisibleChatMemberAccountIDs(report.reportID ?? ''); | ||||
| }, [report, session, isGroupChat, isSystemChat]); | ||||
|
|
||||
| // Get the active chat members by filtering out the pending members with delete action | ||||
| const activeChatMembers = participants.flatMap((accountID) => { | ||||
| const pendingMember = report?.pendingChatMembers?.findLast((member) => member.accountID === accountID.toString()); | ||||
| return !pendingMember || pendingMember.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE ? accountID : []; | ||||
| }); | ||||
|
|
||||
| const isGroupDMChat = useMemo(() => ReportUtils.isDM(report) && participants.length > 1, [report, participants.length]); | ||||
|
|
||||
| const isPrivateNotesFetchTriggered = report?.isLoadingPrivateNotes !== undefined; | ||||
|
|
||||
| const isSelfDM = useMemo(() => ReportUtils.isSelfDM(report), [report]); | ||||
|
|
||||
| useEffect(() => { | ||||
|
|
@@ -307,7 +315,27 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD | |||
| ); | ||||
| }, [report, icons, isMoneyRequestReport, isInvoiceReport, isGroupChat, isThread, styles]); | ||||
|
|
||||
| const reportName = ReportUtils.isDeprecatedGroupDM(report) || isGroupChat ? ReportUtils.getGroupChatName(undefined, false, report.reportID ?? '') : ReportUtils.getReportName(report); | ||||
| const reportName = | ||||
| ReportUtils.isDeprecatedGroupDM(report) || ReportUtils.isGroupChat(report) | ||||
| ? ReportUtils.getGroupChatName(undefined, false, report.reportID ?? '') | ||||
| : ReportUtils.getReportName(report); | ||||
|
|
||||
| const additionalRoomDetails = | ||||
| (isPolicyExpenseChat && !!report?.isOwnPolicyExpenseChat) || ReportUtils.isExpenseReport(report) || isPolicyExpenseChat || isInvoiceRoom | ||||
| ? chatRoomSubtitle | ||||
| : `${translate('threads.in')} ${chatRoomSubtitle}`; | ||||
|
|
||||
| const roomTitle = isPolicyExpenseChat || isGroupChat ? reportName : report?.reportName ?? reportName; | ||||
|
dragnoir marked this conversation as resolved.
|
||||
|
|
||||
| let roomDescription; | ||||
| if (isInvoiceRoom || isPolicyExpenseChat) { | ||||
| roomDescription = translate('common.name'); | ||||
| } else if (isGroupChat) { | ||||
| roomDescription = translate('groupConfirmPage.groupName'); | ||||
| } else { | ||||
| roomDescription = translate('newRoomPage.roomName'); | ||||
| } | ||||
|
|
||||
| return ( | ||||
| <ScreenWrapper testID={ReportDetailsPage.displayName}> | ||||
| <FullPageNotFoundView shouldShow={isEmptyObject(report)}> | ||||
|
|
@@ -317,34 +345,38 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD | |||
| shouldNavigateToTopMostReport={!(route.params && 'backTo' in route.params)} | ||||
| /> | ||||
| <ScrollView style={[styles.flex1]}> | ||||
| <View style={styles.reportDetailsTitleContainer}> | ||||
| <View style={[styles.reportDetailsTitleContainer, !shouldShowRoomName && styles.mb5]}> | ||||
| {renderAvatar} | ||||
| <View style={[styles.reportDetailsRoomInfo, styles.mw100]}> | ||||
| <View style={[styles.alignSelfCenter, styles.w100, styles.mt1]}> | ||||
| <DisplayNames | ||||
| fullTitle={reportName ?? ''} | ||||
| displayNamesWithTooltips={displayNamesWithTooltips} | ||||
| tooltipEnabled | ||||
| numberOfLines={isChatRoom && !isChatThread ? 0 : 1} | ||||
| textStyles={[styles.textHeadline, styles.textAlignCenter, isChatRoom && !isChatThread ? undefined : styles.pre]} | ||||
| shouldUseFullTitle={shouldUseFullTitle} | ||||
| /> | ||||
| </View> | ||||
| {isPolicyAdmin ? ( | ||||
| <PressableWithoutFeedback | ||||
| style={[styles.w100]} | ||||
| disabled={policy?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE} | ||||
| role={CONST.ROLE.BUTTON} | ||||
| accessibilityLabel={chatRoomSubtitle ?? ''} | ||||
| accessible | ||||
| onPress={() => { | ||||
| Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(report?.policyID ?? '')); | ||||
| }} | ||||
| > | ||||
| {chatRoomSubtitleText} | ||||
| </PressableWithoutFeedback> | ||||
| ) : ( | ||||
| chatRoomSubtitleText | ||||
| {!shouldShowRoomName && ( | ||||
| <> | ||||
| <View style={[styles.alignSelfCenter, styles.w100, styles.mt1]}> | ||||
| <DisplayNames | ||||
| fullTitle={reportName ?? ''} | ||||
| displayNamesWithTooltips={displayNamesWithTooltips} | ||||
| tooltipEnabled | ||||
| numberOfLines={isChatRoom && !isChatThread ? 0 : 1} | ||||
| textStyles={[styles.textHeadline, styles.textAlignCenter, isChatRoom && !isChatThread ? undefined : styles.pre]} | ||||
| shouldUseFullTitle={shouldUseFullTitle} | ||||
| /> | ||||
| </View> | ||||
| {isPolicyAdmin ? ( | ||||
| <PressableWithoutFeedback | ||||
| style={[styles.w100]} | ||||
| disabled={policy?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE} | ||||
| role={CONST.ROLE.BUTTON} | ||||
| accessibilityLabel={chatRoomSubtitle ?? ''} | ||||
| accessible | ||||
| onPress={() => { | ||||
| Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(report?.policyID ?? '')); | ||||
| }} | ||||
| > | ||||
| {chatRoomSubtitleText} | ||||
| </PressableWithoutFeedback> | ||||
| ) : ( | ||||
| chatRoomSubtitleText | ||||
| )} | ||||
| </> | ||||
| )} | ||||
| {!isEmptyObject(parentNavigationSubtitleData) && (isMoneyRequestReport || isInvoiceReport || isMoneyRequest || isTaskReport) && ( | ||||
| <ParentNavigationSubtitle | ||||
|
|
@@ -356,6 +388,28 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD | |||
| )} | ||||
| </View> | ||||
| </View> | ||||
| {shouldShowRoomName && ( | ||||
| <OfflineWithFeedback | ||||
| pendingAction={report?.pendingFields?.reportName} | ||||
| errors={report?.errorFields?.reportName} | ||||
| errorRowStyles={[styles.ph5]} | ||||
| onClose={() => Report.clearPolicyRoomNameErrors(report?.reportID)} | ||||
| > | ||||
| <View style={[styles.flex1, !shouldDisableRename && styles.mt3, isGroupChat && styles.mb5]}> | ||||
| <MenuItemWithTopDescription | ||||
| shouldShowRightIcon={!shouldDisableRename} | ||||
| interactive={!shouldDisableRename} | ||||
| title={roomTitle} | ||||
| titleStyle={styles.newKansasLarge} | ||||
| shouldCheckActionAllowedOnPress={false} | ||||
| description={!shouldDisableRename ? roomDescription : ''} | ||||
| furtherDetails={chatRoomSubtitle && !isGroupChat ? additionalRoomDetails : ''} | ||||
| onPress={() => Navigation.navigate(ROUTES.REPORT_SETTINGS_NAME.getRoute(report.reportID))} | ||||
| shouldCenter={shouldDisableRename} | ||||
| /> | ||||
| </View> | ||||
| </OfflineWithFeedback> | ||||
| )} | ||||
| {shouldShowReportDescription && ( | ||||
| <OfflineWithFeedback | ||||
| pendingAction={report.pendingFields?.description} | ||||
|
|
||||
Uh oh!
There was an error while loading. Please reload this page.