diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 0942d799eda7..c86603139a6e 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -778,23 +778,6 @@ function getHeaderMessage(hasSelectableOptions, hasUserToInvite, searchValue, ma return ''; } -/** - * Returns the currency list for sections display - * - * @param {Object} currencyOptions - * @param {String} searchValue - * @returns {Array} - */ -function getCurrencyListForSections(currencyOptions, searchValue) { - const filteredOptions = _.filter(currencyOptions, currencyOption => ( - isSearchStringMatch(searchValue, currencyOption.text))); - - return { - // returns filtered options i.e. options with string match if search text is entered - currencyOptions: filteredOptions, - }; -} - export { addSMSDomainIfPhoneNumber, isCurrentUser, @@ -803,7 +786,6 @@ export { getMemberInviteOptions, getHeaderMessage, getPersonalDetailsForLogins, - getCurrencyListForSections, getIOUConfirmationOptionsFromMyPersonalDetail, getIOUConfirmationOptionsFromParticipants, getSearchText, diff --git a/src/pages/iou/IOUCurrencySelection.js b/src/pages/iou/IOUCurrencySelection.js index 2621b19ce81f..b7affe898beb 100644 --- a/src/pages/iou/IOUCurrencySelection.js +++ b/src/pages/iou/IOUCurrencySelection.js @@ -3,7 +3,6 @@ import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; import ONYXKEYS from '../../ONYXKEYS'; -import * as OptionsListUtils from '../../libs/OptionsListUtils'; import OptionsSelector from '../../components/OptionsSelector'; import Navigation from '../../libs/Navigation/Navigation'; import ScreenWrapper from '../../components/ScreenWrapper'; @@ -41,11 +40,9 @@ class IOUCurrencySelection extends Component { constructor(props) { super(props); - const {currencyOptions} = OptionsListUtils.getCurrencyListForSections(this.getCurrencyOptions(this.props.currencyList), ''); - this.state = { searchValue: '', - currencyData: currencyOptions, + currencyData: this.getCurrencyOptions(this.props.currencyList), }; this.getCurrencyOptions = this.getCurrencyOptions.bind(this); this.getSections = this.getSections.bind(this); @@ -90,13 +87,13 @@ class IOUCurrencySelection extends Component { * @return {void} */ changeSearchValue(searchValue) { - const {currencyOptions} = OptionsListUtils.getCurrencyListForSections( - this.getCurrencyOptions(this.props.currencyList), - searchValue, - ); + const currencyOptions = this.getCurrencyOptions(this.props.currencyList); + const searchRegex = new RegExp(searchValue, 'i'); + const filteredCurrencies = _.filter(currencyOptions, currencyOption => searchRegex.test(currencyOption.text)); + this.setState({ searchValue, - currencyData: currencyOptions, + currencyData: filteredCurrencies, }); }