Skip to content

Commit de8439b

Browse files
authored
Merge pull request #39343 from rayane-djouah/Feat-Redesign-thread-ancestry
Fixes for redesign thread ancestry feature
2 parents 8da0384 + 278ad0c commit de8439b

File tree

7 files changed

+85
-39
lines changed

7 files changed

+85
-39
lines changed

src/components/ParentNavigationSubtitle.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ function ParentNavigationSubtitle({parentNavigationSubtitleData, parentReportAct
3030
const {isOffline} = useNetwork();
3131
const {translate} = useLocalize();
3232

33+
// We should not display the parent navigation subtitle if the user does not have access to the parent chat (the reportName is empty in this case)
34+
if (!reportName) {
35+
return;
36+
}
37+
3338
return (
3439
<PressableWithoutFeedback
3540
onPress={() => {

src/libs/ReportUtils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6002,6 +6002,13 @@ function isReportParticipant(accountID: number, report: OnyxEntry<Report>): bool
60026002
return possibleAccountIDs.includes(accountID);
60036003
}
60046004

6005+
/**
6006+
* Check to see if the current user has access to view the report.
6007+
*/
6008+
function canCurrentUserOpenReport(report: OnyxEntry<Report>): boolean {
6009+
return (isReportParticipant(currentUserAccountID ?? 0, report) || isPublicRoom(report)) && canAccessReport(report, allPolicies, allBetas);
6010+
}
6011+
60056012
function shouldUseFullTitleToDisplay(report: OnyxEntry<Report>): boolean {
60066013
return (
60076014
isMoneyRequestReport(report) || isPolicyExpenseChat(report) || isChatRoom(report) || isChatThread(report) || isTaskReport(report) || isGroupChat(report) || isInvoiceReport(report)
@@ -6530,6 +6537,7 @@ export {
65306537
canBeAutoReimbursed,
65316538
canCreateRequest,
65326539
canCreateTaskInReport,
6540+
canCurrentUserOpenReport,
65336541
canDeleteReportAction,
65346542
canEditFieldOfMoneyRequest,
65356543
canEditMoneyRequest,

src/pages/home/report/RepliesDivider.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import useLocalize from '@hooks/useLocalize';
77
import useTheme from '@hooks/useTheme';
88
import useThemeStyles from '@hooks/useThemeStyles';
99
import variables from '@styles/variables';
10+
import CONST from '@src/CONST';
1011

1112
type RepliesDividerProps = {
1213
/** Whether we should hide thread divider line */
@@ -19,14 +20,17 @@ function RepliesDivider({shouldHideThreadDividerLine}: RepliesDividerProps) {
1920
const {translate} = useLocalize();
2021

2122
return (
22-
<View style={[styles.flexRow, styles.alignItemsCenter, styles.ml5, styles.mt3, styles.mb1]}>
23+
<View
24+
style={[styles.flexRow, styles.alignItemsCenter, styles.ml5, styles.mt3, styles.mb1, styles.userSelectNone]}
25+
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
26+
>
2327
<Icon
2428
src={Expensicons.Thread}
2529
fill={theme.icon}
2630
width={variables.iconSizeExtraSmall}
2731
height={variables.iconSizeExtraSmall}
2832
/>
29-
<Text style={[styles.threadDividerText, styles.textSupporting, styles.ml1]}>{translate('threads.replies')}</Text>
33+
<Text style={[styles.threadDividerText, styles.textSupporting, styles.ml1, styles.userSelectNone]}>{translate('threads.replies')}</Text>
3034
{!shouldHideThreadDividerLine && <View style={[styles.threadDividerLine]} />}
3135
</View>
3236
);

src/pages/home/report/ReportActionItem.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,12 @@ function ReportActionItem({
961961
checkIfContextMenuActive={toggleContextMenuFromActiveReportAction}
962962
setIsEmojiPickerActive={setIsEmojiPickerActive}
963963
/>
964-
<View style={StyleUtils.getReportActionItemStyle(hovered || isWhisper || isContextMenuActive || !!isEmojiPickerActive || draftMessage !== undefined, !!onPress)}>
964+
<View
965+
style={StyleUtils.getReportActionItemStyle(
966+
hovered || isWhisper || isContextMenuActive || !!isEmojiPickerActive || draftMessage !== undefined,
967+
draftMessage === undefined && !!onPress,
968+
)}
969+
>
965970
<OfflineWithFeedback
966971
onClose={() => ReportActions.clearAllRelatedReportActionErrors(report.reportID, action)}
967972
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing

src/pages/home/report/ReportActionItemParentAction.tsx

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,24 @@ function ReportActionItemParentAction({
112112
errorRowStyles={[styles.ml10, styles.mr2]}
113113
onClose={() => Report.navigateToConciergeChatAndDeleteReport(ancestor.report.reportID)}
114114
>
115-
<ThreadDivider ancestor={ancestor} />
115+
<ThreadDivider
116+
ancestor={ancestor}
117+
isLinkDisabled={!ReportUtils.canCurrentUserOpenReport(ReportUtils.getReport(ancestor?.report?.parentReportID))}
118+
/>
116119
<ReportActionItem
117-
onPress={() => {
118-
const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(ancestor.reportAction, ancestor.reportAction.reportActionID ?? '');
119-
// Pop the thread report screen before navigating to the chat report.
120-
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? ''));
121-
if (isVisibleAction && !isOffline) {
122-
// Pop the chat report screen before navigating to the linked report action.
123-
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '', ancestor.reportAction.reportActionID));
124-
}
125-
}}
120+
onPress={
121+
ReportUtils.canCurrentUserOpenReport(ReportUtils.getReport(ancestor?.report?.parentReportID))
122+
? () => {
123+
const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(ancestor.reportAction, ancestor.reportAction.reportActionID ?? '');
124+
// Pop the thread report screen before navigating to the chat report.
125+
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? ''));
126+
if (isVisibleAction && !isOffline) {
127+
// Pop the chat report screen before navigating to the linked report action.
128+
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '', ancestor.reportAction.reportActionID));
129+
}
130+
}
131+
: undefined
132+
}
126133
parentReportAction={parentReportAction}
127134
report={ancestor.report}
128135
reportActions={reportActions}

src/pages/home/report/ReportActionsList.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ function ReportActionsList({
555555
mostRecentIOUReportActionID={mostRecentIOUReportActionID}
556556
shouldHideThreadDividerLine={shouldHideThreadDividerLine}
557557
shouldDisplayNewMarker={shouldDisplayNewMarker(reportAction, index)}
558-
shouldDisplayReplyDivider={sortedReportActions.length > 1}
558+
shouldDisplayReplyDivider={sortedVisibleReportActions.length > 1}
559559
isFirstVisibleReportAction={firstVisibleReportActionID === reportAction.reportActionID}
560560
shouldUseThreadDividerLine={shouldUseThreadDividerLine}
561561
/>
@@ -564,7 +564,6 @@ function ReportActionsList({
564564
report,
565565
linkedReportActionID,
566566
sortedVisibleReportActions,
567-
sortedReportActions.length,
568567
mostRecentIOUReportActionID,
569568
shouldHideThreadDividerLine,
570569
shouldDisplayNewMarker,

src/pages/home/report/ThreadDivider.tsx

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,56 @@ import ROUTES from '@src/ROUTES';
1818
type ThreadDividerProps = {
1919
/** Thread ancestor */
2020
ancestor: Ancestor;
21+
22+
/** Whether the link is disabled */
23+
isLinkDisabled?: boolean;
2124
};
2225

23-
function ThreadDivider({ancestor}: ThreadDividerProps) {
26+
function ThreadDivider({ancestor, isLinkDisabled = false}: ThreadDividerProps) {
2427
const styles = useThemeStyles();
2528
const theme = useTheme();
2629
const {translate} = useLocalize();
2730
const {isOffline} = useNetwork();
2831

2932
return (
30-
<View style={[styles.flexRow, styles.alignItemsCenter, styles.ml5, styles.mt3, styles.mb1]}>
31-
<PressableWithoutFeedback
32-
onPress={() => {
33-
const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(ancestor.reportAction, ancestor.reportAction.reportActionID ?? '');
34-
// Pop the thread report screen before navigating to the chat report.
35-
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? ''));
36-
if (isVisibleAction && !isOffline) {
37-
// Pop the chat report screen before navigating to the linked report action.
38-
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '', ancestor.reportAction.reportActionID));
39-
}
40-
}}
41-
accessibilityLabel={translate('threads.thread')}
42-
role={CONST.ROLE.BUTTON}
43-
style={[styles.flexRow, styles.alignItemsCenter, styles.gap1]}
44-
>
45-
<Icon
46-
src={Expensicons.Thread}
47-
fill={theme.link}
48-
width={variables.iconSizeExtraSmall}
49-
height={variables.iconSizeExtraSmall}
50-
/>
51-
<Text style={[styles.threadDividerText, styles.link]}>{translate('threads.thread')}</Text>
52-
</PressableWithoutFeedback>
33+
<View
34+
style={[styles.flexRow, styles.alignItemsCenter, styles.ml5, styles.mt3, styles.mb1, styles.userSelectNone]}
35+
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
36+
>
37+
{isLinkDisabled ? (
38+
<>
39+
<Icon
40+
src={Expensicons.Thread}
41+
fill={theme.icon}
42+
width={variables.iconSizeExtraSmall}
43+
height={variables.iconSizeExtraSmall}
44+
/>
45+
<Text style={[styles.threadDividerText, styles.textSupporting, styles.ml1, styles.userSelectNone]}>{translate('threads.thread')}</Text>
46+
</>
47+
) : (
48+
<PressableWithoutFeedback
49+
onPress={() => {
50+
const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(ancestor.reportAction, ancestor.reportAction.reportActionID ?? '');
51+
// Pop the thread report screen before navigating to the chat report.
52+
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? ''));
53+
if (isVisibleAction && !isOffline) {
54+
// Pop the chat report screen before navigating to the linked report action.
55+
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '', ancestor.reportAction.reportActionID));
56+
}
57+
}}
58+
accessibilityLabel={translate('threads.thread')}
59+
role={CONST.ROLE.BUTTON}
60+
style={[styles.flexRow, styles.alignItemsCenter, styles.gap1]}
61+
>
62+
<Icon
63+
src={Expensicons.Thread}
64+
fill={theme.link}
65+
width={variables.iconSizeExtraSmall}
66+
height={variables.iconSizeExtraSmall}
67+
/>
68+
<Text style={[styles.threadDividerText, styles.link]}>{translate('threads.thread')}</Text>
69+
</PressableWithoutFeedback>
70+
)}
5371
{!ancestor.shouldDisplayNewMarker && <View style={[styles.threadDividerLine]} />}
5472
</View>
5573
);

0 commit comments

Comments
 (0)