Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, {useCallback, useEffect, useMemo, useState} from 'react';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import * as Expensicons from '@components/Icon/Expensicons';

Check warning on line 3 in src/pages/workspace/receiptPartners/ChangeReceiptBillingAccountPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'@components/Icon/Expensicons' import is restricted from being used by a pattern. Direct imports from Icon/Expensicons are deprecated. Please use lazy loading hooks instead. Use `useMemoizedLazyExpensifyIcons` from @hooks/useLazyAsset. See docs/LAZY_ICONS_AND_ILLUSTRATIONS.md for details

Check warning on line 3 in src/pages/workspace/receiptPartners/ChangeReceiptBillingAccountPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'@components/Icon/Expensicons' import is restricted from being used. Direct imports from @components/Icon/Expensicons are deprecated. Please use lazy loading hooks instead. Use `useMemoizedLazyExpensifyIcons` from @hooks/useLazyAsset. See docs/LAZY_ICONS_AND_ILLUSTRATIONS.md for details
import ScreenWrapper from '@components/ScreenWrapper';
import SelectionList from '@components/SelectionListWithSections';
import InviteMemberListItem from '@components/SelectionListWithSections/InviteMemberListItem';
import SelectionList from '@components/SelectionList';
import InviteMemberListItem from '@components/SelectionList/ListItem/InviteMemberListItem';
import Text from '@components/Text';
import useDebouncedState from '@hooks/useDebouncedState';
import useLocalize from '@hooks/useLocalize';
Expand Down Expand Up @@ -85,7 +85,7 @@
return membersList;
}, [isOffline, policy?.employeeList, localeCompare, selectedOption]);

const sections = useMemo(() => {
const data = useMemo(() => {
if (workspaceMembers.length === 0) {
return [];
}
Expand All @@ -98,13 +98,7 @@
membersToDisplay = tokenizedSearch(workspaceMembers, searchValue, (option) => [option.text ?? '', option.alternateText ?? '']);
}

return [
{
title: undefined,
data: membersToDisplay,
shouldShow: true,
},
];
return membersToDisplay;
}, [workspaceMembers, countryCode, debouncedSearchTerm]);

useEffect(() => {
Expand All @@ -130,8 +124,18 @@
const headerMessage = useMemo(() => {
const searchValue = debouncedSearchTerm.trim().toLowerCase();

return getHeaderMessage(sections?.at(0)?.data.length !== 0, false, searchValue, countryCode);
}, [debouncedSearchTerm, sections, countryCode]);
return getHeaderMessage(data.length !== 0, false, searchValue, countryCode);
}, [debouncedSearchTerm, data.length, countryCode]);

const textInputOptions = useMemo(
() => ({
label: textInputLabel,
value: searchTerm,
onChangeText: setSearchTerm,
headerMessage,
}),
[headerMessage, searchTerm, setSearchTerm, textInputLabel],
);

return (
<AccessOrNotFoundWrapper
Expand All @@ -143,19 +147,17 @@
<HeaderWithBackButton title={translate('workspace.receiptPartners.uber.centralBillingAccount')} />
<Text style={[styles.ph5, styles.pb3]}>{translate('workspace.receiptPartners.uber.centralBillingDescription')}</Text>
<SelectionList
sections={sections}
ListItem={InviteMemberListItem}
textInputLabel={textInputLabel}
textInputValue={searchTerm}
onChangeText={setSearchTerm}
headerMessage={headerMessage}
data={data}
onSelectRow={toggleOption}
showScrollIndicator
ListItem={InviteMemberListItem}
textInputOptions={textInputOptions}
shouldShowTextInput={shouldShowTextInput}
initiallyFocusedItemKey={centralBillingAccountEmail}
shouldPreventDefaultFocusOnSelectRow={!canUseTouchScreen()}
initiallyFocusedOptionKey={centralBillingAccountEmail}
disableMaintainingScrollPosition
shouldUpdateFocusedIndex
shouldShowTextInput={shouldShowTextInput}
addBottomSafeAreaPadding
showScrollIndicator
/>
</ScreenWrapper>
</AccessOrNotFoundWrapper>
Expand Down
Loading