Skip to content

Commit 4941197

Browse files
authored
Merge pull request Expensify#72840 from callstack-internal/part-10-refactor-LogiUtils-to-deprecate-onyx-connect
[Part 10] Refactor LoginUtils to deprecate onyx connect
2 parents f4ad3fc + 3c002cc commit 4941197

18 files changed

Lines changed: 47 additions & 24 deletions

src/libs/OptionsListUtils/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2205,8 +2205,14 @@ function getMemberInviteOptions(
22052205
/**
22062206
* Helper method that returns the text to be used for the header's message and title (if any)
22072207
*/
2208-
function getHeaderMessage(hasSelectableOptions: boolean, hasUserToInvite: boolean, searchValue: string, hasMatchedParticipant = false): string {
2209-
const isValidPhone = parsePhoneNumber(appendCountryCode(searchValue)).possible;
2208+
function getHeaderMessage(
2209+
hasSelectableOptions: boolean,
2210+
hasUserToInvite: boolean,
2211+
searchValue: string,
2212+
hasMatchedParticipant = false,
2213+
countryCode: OnyxEntry<number> = CONST.DEFAULT_COUNTRY_CODE,
2214+
): string {
2215+
const isValidPhone = parsePhoneNumber(appendCountryCodeWithCountryCode(searchValue, countryCode)).possible;
22102216

22112217
const isValidEmail = Str.isValidEmail(searchValue);
22122218

src/pages/InviteReportParticipantsPage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ function InviteReportParticipantsPage({report, didScreenTransitionEnd}: InviteRe
165165
selectedOptionsForDisplay.length + availableOptions.recentReports.length + availableOptions.personalDetails.length !== 0,
166166
!!availableOptions.userToInvite,
167167
processedLogin,
168+
false,
169+
countryCode,
168170
);
169171
}, [searchTerm, availableOptions, selectedOptionsForDisplay, excludedUsers, translate, reportName, countryCode]);
170172

src/pages/OnboardingWorkspaceInvite/BaseOnboardingWorkspaceInvite.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ function BaseOnboardingWorkspaceInvite({shouldUseNativeStyles}: BaseOnboardingWo
299299
) {
300300
return translate('messages.userIsAlreadyMember', {login: searchValue, name: policy?.name ?? ''});
301301
}
302-
return getHeaderMessage(personalDetails.length !== 0, usersToInvite.length > 0, searchValue);
303-
}, [excludedUsers, translate, debouncedSearchTerm, policy?.name, usersToInvite, personalDetails.length]);
302+
return getHeaderMessage(personalDetails.length !== 0, usersToInvite.length > 0, searchValue, false, countryCode);
303+
}, [excludedUsers, translate, debouncedSearchTerm, policy?.name, usersToInvite, personalDetails.length, countryCode]);
304304

305305
const footerContent = useMemo(
306306
() => (

src/pages/Share/ShareTab.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ function ShareTab({ref}: ShareTabProps) {
105105
const [sections, header] = useMemo(() => {
106106
const newSections = [];
107107
newSections.push({title: textInputValue.trim() === '' ? translate('search.recentChats') : undefined, data: styledRecentReports});
108-
const headerMessage = getHeaderMessage(styledRecentReports.length !== 0, false, textInputValue.trim(), false);
108+
const headerMessage = getHeaderMessage(styledRecentReports.length !== 0, false, textInputValue.trim(), false, countryCode);
109109
return [newSections, headerMessage];
110-
}, [textInputValue, styledRecentReports, translate]);
110+
}, [textInputValue, styledRecentReports, translate, countryCode]);
111111

112112
const onSelectRow = (item: OptionData) => {
113113
let reportID = item?.reportID ?? CONST.DEFAULT_NUMBER_ID;

src/pages/iou/request/MoneyRequestAccountantSelector.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ function MoneyRequestAccountantSelector({onFinish, onAccountantSelected, iouType
166166
(chatOptions.personalDetails ?? []).length + (chatOptions.recentReports ?? []).length !== 0,
167167
!!chatOptions?.userToInvite,
168168
debouncedSearchTerm.trim(),
169+
false,
170+
countryCode,
169171
);
170172

171173
return [newSections, headerMessage];
@@ -177,8 +179,9 @@ function MoneyRequestAccountantSelector({onFinish, onAccountantSelected, iouType
177179
chatOptions.userToInvite,
178180
debouncedSearchTerm,
179181
personalDetails,
180-
translate,
181182
reportAttributesDerived,
183+
translate,
184+
countryCode,
182185
]);
183186

184187
const selectAccountant = useCallback(

src/pages/iou/request/MoneyRequestAttendeeSelector.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ function MoneyRequestAttendeeSelector({attendees = [], onFinish, onAttendeesAdde
213213
!!chatOptions?.userToInvite,
214214
cleanSearchTerm,
215215
attendees.some((attendee) => getPersonalDetailSearchTerms(attendee).join(' ').toLowerCase().includes(cleanSearchTerm)),
216+
countryCode,
216217
);
217218

218219
return [newSections, headerMessage];
@@ -225,8 +226,9 @@ function MoneyRequestAttendeeSelector({attendees = [], onFinish, onAttendeesAdde
225226
cleanSearchTerm,
226227
attendees,
227228
personalDetails,
228-
translate,
229229
reportAttributesDerived,
230+
translate,
231+
countryCode,
230232
]);
231233

232234
const addAttendeeToSelection = useCallback(

src/pages/iou/request/MoneyRequestParticipantsSelector.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ function MoneyRequestParticipantsSelector({
260260
!!chatOptions?.userToInvite,
261261
debouncedSearchTerm.trim(),
262262
participants.some((participant) => getPersonalDetailSearchTerms(participant).join(' ').toLowerCase().includes(cleanSearchTerm)),
263+
countryCode,
263264
),
264265
[
265266
chatOptions.personalDetails,
@@ -270,6 +271,7 @@ function MoneyRequestParticipantsSelector({
270271
cleanSearchTerm,
271272
debouncedSearchTerm,
272273
participants,
274+
countryCode,
273275
],
274276
);
275277
/**

src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ function BaseShareLogList({onAttachLogToReport}: BaseShareLogListProps) {
6363
(filteredOptions.recentReports?.length || 0) + (filteredOptions.personalDetails?.length || 0) !== 0,
6464
!!filteredOptions.userToInvite,
6565
debouncedSearchValue.trim(),
66+
false,
67+
countryCode,
6668
);
6769

6870
return {...filteredOptions, headerMessage};

src/pages/settings/Profile/CustomStatus/VacationDelegatePage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function useOptions() {
5656
countryCode,
5757
);
5858

59-
const headerMessage = getHeaderMessage((recentReports?.length || 0) + (personalDetails?.length || 0) !== 0, !!userToInvite, '');
59+
const headerMessage = getHeaderMessage((recentReports?.length || 0) + (personalDetails?.length || 0) !== 0, !!userToInvite, '', false, countryCode);
6060

6161
return {
6262
userToInvite,
@@ -76,6 +76,8 @@ function useOptions() {
7676
(filteredOptions.recentReports?.length || 0) + (filteredOptions.personalDetails?.length || 0) !== 0,
7777
!!filteredOptions.userToInvite,
7878
debouncedSearchValue,
79+
false,
80+
countryCode,
7981
);
8082

8183
return {

src/pages/settings/Security/AddDelegate/AddDelegatePage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function useOptions() {
5757
countryCode,
5858
);
5959

60-
const headerMessage = getHeaderMessage((recentReports?.length || 0) + (personalDetails?.length || 0) !== 0, !!userToInvite, '');
60+
const headerMessage = getHeaderMessage((recentReports?.length || 0) + (personalDetails?.length || 0) !== 0, !!userToInvite, '', false, countryCode);
6161

6262
if (isLoading) {
6363
// eslint-disable-next-line react-compiler/react-compiler

0 commit comments

Comments
 (0)