Skip to content

Commit 7b9e55e

Browse files
authored
Merge pull request Expensify#55177 from ikevin127/ikevin127-removeReportWelcomePressable
Remove custom report welcome message pressable functionality
2 parents 9be0b9f + 2c3bb0c commit 7b9e55e

File tree

2 files changed

+110
-125
lines changed

2 files changed

+110
-125
lines changed

src/components/ReportWelcomeText.tsx

Lines changed: 40 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,30 @@ import useLocalize from '@hooks/useLocalize';
66
import usePermissions from '@hooks/usePermissions';
77
import useThemeStyles from '@hooks/useThemeStyles';
88
import Navigation from '@libs/Navigation/Navigation';
9-
import * as OptionsListUtils from '@libs/OptionsListUtils';
9+
import {getPersonalDetailsForAccountIDs} from '@libs/OptionsListUtils';
1010
import {getPolicy} from '@libs/PolicyUtils';
11-
import * as ReportUtils from '@libs/ReportUtils';
11+
import {
12+
getDisplayNameForParticipant,
13+
getDisplayNamesWithTooltips,
14+
getParticipantsAccountIDsForDisplay,
15+
getPolicyName,
16+
getReportName,
17+
isArchivedNonExpenseReport,
18+
isChatRoom as isChatRoomReportUtils,
19+
isConciergeChatReport,
20+
isInvoiceRoom as isInvoiceRoomReportUtils,
21+
isOptimisticPersonalDetail,
22+
isPolicyExpenseChat as isPolicyExpenseChatReportUtils,
23+
isSelfDM as isSelfDMReportUtils,
24+
isSystemChat as isSystemChatReportUtils,
25+
temporary_getMoneyRequestOptions,
26+
} from '@libs/ReportUtils';
1227
import SidebarUtils from '@libs/SidebarUtils';
1328
import CONST from '@src/CONST';
1429
import type {IOUType} from '@src/CONST';
1530
import ONYXKEYS from '@src/ONYXKEYS';
1631
import ROUTES from '@src/ROUTES';
1732
import type {Policy, Report} from '@src/types/onyx';
18-
import {PressableWithoutFeedback} from './Pressable';
1933
import RenderHTML from './RenderHTML';
2034
import Text from './Text';
2135
import UserDetailsTooltip from './UserDetailsTooltip';
@@ -32,21 +46,20 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) {
3246
const {translate} = useLocalize();
3347
const styles = useThemeStyles();
3448
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST);
35-
const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report);
49+
const isPolicyExpenseChat = isPolicyExpenseChatReportUtils(report);
3650
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
3751
const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID || undefined}`);
38-
const isArchivedRoom = ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs);
39-
const isChatRoom = ReportUtils.isChatRoom(report);
40-
const isSelfDM = ReportUtils.isSelfDM(report);
41-
const isInvoiceRoom = ReportUtils.isInvoiceRoom(report);
42-
const isSystemChat = ReportUtils.isSystemChat(report);
52+
const isArchivedRoom = isArchivedNonExpenseReport(report, reportNameValuePairs);
53+
const isChatRoom = isChatRoomReportUtils(report);
54+
const isSelfDM = isSelfDMReportUtils(report);
55+
const isInvoiceRoom = isInvoiceRoomReportUtils(report);
56+
const isSystemChat = isSystemChatReportUtils(report);
4357
const isDefault = !(isChatRoom || isPolicyExpenseChat || isSelfDM || isInvoiceRoom || isSystemChat);
44-
const participantAccountIDs = ReportUtils.getParticipantsAccountIDsForDisplay(report, undefined, true, true);
58+
const participantAccountIDs = getParticipantsAccountIDsForDisplay(report, undefined, true, true);
4559
const isMultipleParticipant = participantAccountIDs.length > 1;
46-
const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(OptionsListUtils.getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails), isMultipleParticipant);
60+
const displayNamesWithTooltips = getDisplayNamesWithTooltips(getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails), isMultipleParticipant);
4761
const welcomeMessage = SidebarUtils.getWelcomeMessage(report, policy);
48-
const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, policy, participantAccountIDs);
49-
const canEditReportDescription = ReportUtils.canEditReportDescription(report, policy);
62+
const moneyRequestOptions = temporary_getMoneyRequestOptions(report, policy, participantAccountIDs);
5063
const {canUseCombinedTrackSubmit} = usePermissions();
5164
const filteredOptions = moneyRequestOptions.filter(
5265
(item): item is Exclude<IOUType, typeof CONST.IOU.TYPE.REQUEST | typeof CONST.IOU.TYPE.SEND | typeof CONST.IOU.TYPE.CREATE | typeof CONST.IOU.TYPE.INVOICE> =>
@@ -60,8 +73,7 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) {
6073
)}`,
6174
)
6275
.join(', ');
63-
const canEditPolicyDescription = ReportUtils.canEditPolicyDescription(policy);
64-
const reportName = ReportUtils.getReportName(report);
76+
const reportName = getReportName(report);
6577
const shouldShowUsePlusButtonText =
6678
(moneyRequestOptions.includes(CONST.IOU.TYPE.PAY) ||
6779
moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT) ||
@@ -105,75 +117,45 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) {
105117
<View style={[styles.mt3, styles.mw100]}>
106118
{isPolicyExpenseChat &&
107119
(welcomeMessage?.messageHtml ? (
108-
<PressableWithoutFeedback
109-
onPress={() => {
110-
if (!canEditPolicyDescription) {
111-
return;
112-
}
113-
Navigation.navigate(ROUTES.WORKSPACE_PROFILE_DESCRIPTION.getRoute(policy?.id));
114-
}}
115-
style={[styles.renderHTML, canEditPolicyDescription ? styles.cursorPointer : styles.cursorText]}
116-
accessibilityLabel={translate('reportDescriptionPage.roomDescription')}
117-
>
120+
<View style={[styles.renderHTML, styles.cursorText]}>
118121
<RenderHTML html={welcomeMessage.messageHtml} />
119-
</PressableWithoutFeedback>
122+
</View>
120123
) : (
121124
<Text>
122125
<Text>{welcomeMessage.phrase1}</Text>
123-
<Text style={[styles.textStrong]}>{ReportUtils.getDisplayNameForParticipant(report?.ownerAccountID)}</Text>
126+
<Text style={[styles.textStrong]}>{getDisplayNameForParticipant(report?.ownerAccountID)}</Text>
124127
<Text>{welcomeMessage.phrase2}</Text>
125-
<Text style={[styles.textStrong]}>{ReportUtils.getPolicyName(report)}</Text>
128+
<Text style={[styles.textStrong]}>{getPolicyName(report)}</Text>
126129
<Text>{welcomeMessage.phrase3}</Text>
127130
</Text>
128131
))}
129132
{isInvoiceRoom &&
130133
!isArchivedRoom &&
131134
(welcomeMessage?.messageHtml ? (
132-
<PressableWithoutFeedback
133-
onPress={() => {
134-
if (!canEditReportDescription) {
135-
return;
136-
}
137-
const activeRoute = Navigation.getActiveRoute();
138-
Navigation.navigate(ROUTES.REPORT_DESCRIPTION.getRoute(report?.reportID, activeRoute));
139-
}}
140-
style={[styles.renderHTML, canEditReportDescription ? styles.cursorPointer : styles.cursorText]}
141-
accessibilityLabel={translate('reportDescriptionPage.roomDescription')}
142-
>
135+
<View style={[styles.renderHTML, styles.cursorText]}>
143136
<RenderHTML html={welcomeMessage.messageHtml} />
144-
</PressableWithoutFeedback>
137+
</View>
145138
) : (
146139
<Text>
147140
<Text>{welcomeMessage.phrase1}</Text>
148141
<Text>
149142
{report?.invoiceReceiver?.type === CONST.REPORT.INVOICE_RECEIVER_TYPE.INDIVIDUAL ? (
150-
<Text style={[styles.textStrong]}>{ReportUtils.getDisplayNameForParticipant(report?.invoiceReceiver?.accountID)}</Text>
143+
<Text style={[styles.textStrong]}>{getDisplayNameForParticipant(report?.invoiceReceiver?.accountID)}</Text>
151144
) : (
152145
<Text style={[styles.textStrong]}>{getPolicy(report?.invoiceReceiver?.policyID)?.name}</Text>
153146
)}
154147
</Text>
155148
<Text>{` ${translate('common.and')} `}</Text>
156-
<Text style={[styles.textStrong]}>{ReportUtils.getPolicyName(report)}</Text>
149+
<Text style={[styles.textStrong]}>{getPolicyName(report)}</Text>
157150
<Text>{welcomeMessage.phrase2}</Text>
158151
</Text>
159152
))}
160153
{isChatRoom &&
161154
(!isInvoiceRoom || isArchivedRoom) &&
162155
(welcomeMessage?.messageHtml ? (
163-
<PressableWithoutFeedback
164-
onPress={() => {
165-
const activeRoute = Navigation.getActiveRoute();
166-
if (canEditReportDescription) {
167-
Navigation.navigate(ROUTES.REPORT_DESCRIPTION.getRoute(report?.reportID, activeRoute));
168-
return;
169-
}
170-
Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report?.reportID, activeRoute));
171-
}}
172-
style={styles.renderHTML}
173-
accessibilityLabel={translate('reportDescriptionPage.roomDescription')}
174-
>
156+
<View style={styles.renderHTML}>
175157
<RenderHTML html={welcomeMessage.messageHtml} />
176-
</PressableWithoutFeedback>
158+
</View>
177159
) : (
178160
<Text>
179161
<Text>{welcomeMessage.phrase1}</Text>
@@ -183,7 +165,7 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) {
183165
onPress={navigateToReport}
184166
suppressHighlighting
185167
>
186-
{ReportUtils.getReportName(report)}
168+
{getReportName(report)}
187169
</Text>
188170
)}
189171
{welcomeMessage.phrase2 !== undefined && <Text>{welcomeMessage.phrase2}</Text>}
@@ -206,7 +188,7 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) {
206188
// eslint-disable-next-line react/no-array-index-key
207189
<Text key={`${displayName}${index}`}>
208190
<UserDetailsTooltip accountID={accountID}>
209-
{ReportUtils.isOptimisticPersonalDetail(accountID) ? (
191+
{isOptimisticPersonalDetail(accountID) ? (
210192
<Text style={[styles.textStrong]}>{displayName}</Text>
211193
) : (
212194
<Text
@@ -226,7 +208,7 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) {
226208
</Text>
227209
)}
228210
{shouldShowUsePlusButtonText && <Text>{translate('reportActionsView.usePlusButton', {additionalText})}</Text>}
229-
{ReportUtils.isConciergeChatReport(report) && <Text>{translate('reportActionsView.askConcierge')}</Text>}
211+
{isConciergeChatReport(report) && <Text>{translate('reportActionsView.askConcierge')}</Text>}
230212
</View>
231213
</>
232214
);

0 commit comments

Comments
 (0)