From 2b85c510df5fab83dbaa2b5e6d1955b569e09a8f Mon Sep 17 00:00:00 2001 From: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com> Date: Fri, 2 Dec 2022 23:04:15 +0100 Subject: [PATCH 1/3] Fixed a regression related to getCurrencyListForSections --- src/libs/OptionsListUtils.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 6ae60712b19c..00c00333d979 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -783,6 +783,10 @@ function getHeaderMessage(hasSelectableOptions, hasUserToInvite, searchValue, ma * @returns {Array} */ function getCurrencyListForSections(currencyOptions, searchValue) { + if (!searchValue) { + return {currencyOptions}; + } + const filteredOptions = _.filter(currencyOptions, currencyOption => ( isSearchStringMatch(searchValue, currencyOption.text))); From 2428eb4eaed8ca26215f7e849807cb5f551f160e Mon Sep 17 00:00:00 2001 From: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com> Date: Mon, 5 Dec 2022 23:11:43 +0100 Subject: [PATCH 2/3] call getCurrencyListForSections only if we have a searchValue --- src/pages/iou/IOUCurrencySelection.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/iou/IOUCurrencySelection.js b/src/pages/iou/IOUCurrencySelection.js index 2621b19ce81f..01e80ad0ae38 100644 --- a/src/pages/iou/IOUCurrencySelection.js +++ b/src/pages/iou/IOUCurrencySelection.js @@ -41,7 +41,7 @@ class IOUCurrencySelection extends Component { constructor(props) { super(props); - const {currencyOptions} = OptionsListUtils.getCurrencyListForSections(this.getCurrencyOptions(this.props.currencyList), ''); + const {currencyOptions} = this.getCurrencyOptions(this.props.currencyList); this.state = { searchValue: '', @@ -90,10 +90,10 @@ class IOUCurrencySelection extends Component { * @return {void} */ changeSearchValue(searchValue) { - const {currencyOptions} = OptionsListUtils.getCurrencyListForSections( + const {currencyOptions} = searchValue ? OptionsListUtils.getCurrencyListForSections( this.getCurrencyOptions(this.props.currencyList), searchValue, - ); + ) : this.getCurrencyOptions(this.props.currencyList); this.setState({ searchValue, currencyData: currencyOptions, From 457f3b497e954c8edb5126549abba44a6ec72415 Mon Sep 17 00:00:00 2001 From: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com> Date: Mon, 5 Dec 2022 23:34:44 +0100 Subject: [PATCH 3/3] Revert "call getCurrencyListForSections only if we have a searchValue" This reverts commit 2428eb4eaed8ca26215f7e849807cb5f551f160e. --- src/pages/iou/IOUCurrencySelection.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/iou/IOUCurrencySelection.js b/src/pages/iou/IOUCurrencySelection.js index 01e80ad0ae38..2621b19ce81f 100644 --- a/src/pages/iou/IOUCurrencySelection.js +++ b/src/pages/iou/IOUCurrencySelection.js @@ -41,7 +41,7 @@ class IOUCurrencySelection extends Component { constructor(props) { super(props); - const {currencyOptions} = this.getCurrencyOptions(this.props.currencyList); + const {currencyOptions} = OptionsListUtils.getCurrencyListForSections(this.getCurrencyOptions(this.props.currencyList), ''); this.state = { searchValue: '', @@ -90,10 +90,10 @@ class IOUCurrencySelection extends Component { * @return {void} */ changeSearchValue(searchValue) { - const {currencyOptions} = searchValue ? OptionsListUtils.getCurrencyListForSections( + const {currencyOptions} = OptionsListUtils.getCurrencyListForSections( this.getCurrencyOptions(this.props.currencyList), searchValue, - ) : this.getCurrencyOptions(this.props.currencyList); + ); this.setState({ searchValue, currencyData: currencyOptions,