Skip to content

Commit

Permalink
Revert "[NoQA] Tests for group chat name"
Browse files Browse the repository at this point in the history
  • Loading branch information
marcaaron authored Jun 18, 2024
1 parent e30122d commit 928cb1a
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 575 deletions.
10 changes: 0 additions & 10 deletions __mocks__/@react-native-reanimated/index.ts

This file was deleted.

17 changes: 8 additions & 9 deletions src/pages/InviteReportParticipantsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import InviteMemberListItem from '@components/SelectionList/InviteMemberListItem
import type {Section} from '@components/SelectionList/types';
import withNavigationTransitionEnd from '@components/withNavigationTransitionEnd';
import type {WithNavigationTransitionEndProps} from '@components/withNavigationTransitionEnd';
import useDebouncedState from '@hooks/useDebouncedState';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
Expand Down Expand Up @@ -45,7 +44,7 @@ function InviteReportParticipantsPage({betas, personalDetails, report, didScreen

const styles = useThemeStyles();
const {translate} = useLocalize();
const [searchTerm, debouncedSearchTerm, setSearchTerm] = useDebouncedState('');
const [searchTerm, setSearchTerm] = useState('');
const [selectedOptions, setSelectedOptions] = useState<ReportUtils.OptionData[]>([]);
const [invitePersonalDetails, setInvitePersonalDetails] = useState<ReportUtils.OptionData[]>([]);
const [recentReports, setRecentReports] = useState<ReportUtils.OptionData[]>([]);
Expand All @@ -58,7 +57,7 @@ function InviteReportParticipantsPage({betas, personalDetails, report, didScreen
);

useEffect(() => {
const inviteOptions = OptionsListUtils.getMemberInviteOptions(options.personalDetails, betas ?? [], debouncedSearchTerm, excludedUsers, false, options.reports, true);
const inviteOptions = OptionsListUtils.getMemberInviteOptions(options.personalDetails, betas ?? [], searchTerm, excludedUsers, false, options.reports, true);

// Update selectedOptions with the latest personalDetails information
const detailsMap: Record<string, OptionsListUtils.MemberForList> = {};
Expand All @@ -78,7 +77,7 @@ function InviteReportParticipantsPage({betas, personalDetails, report, didScreen
setRecentReports(inviteOptions.recentReports);
setSelectedOptions(newSelectedOptions);
// eslint-disable-next-line react-hooks/exhaustive-deps -- we don't want to recalculate when selectedOptions change
}, [personalDetails, betas, debouncedSearchTerm, excludedUsers, options]);
}, [personalDetails, betas, searchTerm, excludedUsers, options]);

const sections = useMemo(() => {
const sectionsArr: Sections = [];
Expand All @@ -89,11 +88,11 @@ function InviteReportParticipantsPage({betas, personalDetails, report, didScreen

// Filter all options that is a part of the search term or in the personal details
let filterSelectedOptions = selectedOptions;
if (debouncedSearchTerm !== '') {
if (searchTerm !== '') {
filterSelectedOptions = selectedOptions.filter((option) => {
const accountID = option?.accountID;
const isOptionInPersonalDetails = invitePersonalDetails.some((personalDetail) => accountID && personalDetail?.accountID === accountID);
const searchValue = OptionsListUtils.getSearchValueForPhoneOrEmail(debouncedSearchTerm);
const searchValue = OptionsListUtils.getSearchValueForPhoneOrEmail(searchTerm);
const isPartOfSearchTerm = !!option.text?.toLowerCase().includes(searchValue) || !!option.login?.toLowerCase().includes(searchValue);
return isPartOfSearchTerm || isOptionInPersonalDetails;
});
Expand Down Expand Up @@ -131,7 +130,7 @@ function InviteReportParticipantsPage({betas, personalDetails, report, didScreen
}

return sectionsArr;
}, [invitePersonalDetails, debouncedSearchTerm, selectedOptions, translate, userToInvite, areOptionsInitialized, recentReports]);
}, [invitePersonalDetails, searchTerm, selectedOptions, translate, userToInvite, areOptionsInitialized, recentReports]);

const toggleOption = useCallback(
(option: OptionsListUtils.MemberForList) => {
Expand Down Expand Up @@ -172,7 +171,7 @@ function InviteReportParticipantsPage({betas, personalDetails, report, didScreen
}, [selectedOptions, backRoute, reportID, validate]);

const headerMessage = useMemo(() => {
const searchValue = debouncedSearchTerm.trim().toLowerCase();
const searchValue = searchTerm.trim().toLowerCase();
const expensifyEmails = CONST.EXPENSIFY_EMAILS as string[];
if (!userToInvite && expensifyEmails.includes(searchValue)) {
return translate('messages.errorMessageInvalidEmail');
Expand All @@ -188,7 +187,7 @@ function InviteReportParticipantsPage({betas, personalDetails, report, didScreen
return translate('messages.userIsAlreadyMember', {login: searchValue, name: reportName ?? ''});
}
return OptionsListUtils.getHeaderMessage(invitePersonalDetails.length !== 0, !!userToInvite, searchValue);
}, [debouncedSearchTerm, userToInvite, excludedUsers, invitePersonalDetails, translate, reportName]);
}, [searchTerm, userToInvite, excludedUsers, invitePersonalDetails, translate, reportName]);

const footerContent = useMemo(
() => (
Expand Down
Loading

0 comments on commit 928cb1a

Please sign in to comment.