From c90b7675cd6341c1515fa93364c120a0a719e59a Mon Sep 17 00:00:00 2001 From: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:47:45 +0100 Subject: [PATCH] Use keyForList in OptionsSelector's isSelected logic --- src/components/OptionsList/BaseOptionsList.tsx | 10 +--------- src/libs/OptionsListUtils.ts | 2 ++ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/components/OptionsList/BaseOptionsList.tsx b/src/components/OptionsList/BaseOptionsList.tsx index 1975c0f1a88e..6f265bfb8440 100644 --- a/src/components/OptionsList/BaseOptionsList.tsx +++ b/src/components/OptionsList/BaseOptionsList.tsx @@ -175,15 +175,7 @@ function BaseOptionsList( const renderItem: SectionListRenderItem = ({item, index, section}) => { const isItemDisabled = isDisabled || !!section.isDisabled || !!item.isDisabled; const isSelected = selectedOptions?.some((option) => { - if (option.accountID && option.accountID === item.accountID) { - return true; - } - - if (option.reportID && option.reportID === item.reportID) { - return true; - } - - if (option.policyID && option.policyID === item.policyID) { + if (option.keyForList && option.keyForList === item.keyForList) { return true; } diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 8cbe5bfa2d23..b6518b361381 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -66,6 +66,7 @@ type PayeePersonalDetails = { descriptiveText: string; login: string; accountID: number; + keyForList: string; }; type CategorySection = { @@ -1737,6 +1738,7 @@ function getIOUConfirmationOptionsFromPayeePersonalDetail(personalDetail: Person descriptiveText: amountText, login: personalDetail.login ?? '', accountID: personalDetail.accountID, + keyForList: String(personalDetail.accountID), }; }