diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 15239b09dd79..05d56f390b2a 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -155,7 +155,7 @@ function MoneyRequestConfirmationList(props) { const formattedParticipantsList = _.union(formattedSelectedParticipants, formattedUnselectedParticipants); const myIOUAmount = IOUUtils.calculateAmount(selectedParticipants.length, props.iouAmount, true); - const formattedPayeePersonalDetails = OptionsListUtils.getIOUConfirmationOptionsFromPayeePersonalDetail( + const formattedPayeeOption = OptionsListUtils.getIOUConfirmationOptionsFromPayeePersonalDetail( payeePersonalDetails, CurrencyUtils.convertToDisplayString(myIOUAmount, props.iouCurrencyCode), ); @@ -163,7 +163,7 @@ function MoneyRequestConfirmationList(props) { sections.push( { title: translate('moneyRequestConfirmationList.whoPaid'), - data: [formattedPayeePersonalDetails], + data: [formattedPayeeOption], shouldShow: true, indexOffset: 0, }, @@ -211,13 +211,13 @@ function MoneyRequestConfirmationList(props) { const toggleOption = useCallback( (option) => { // Return early if selected option is currently logged in user. - if (option.login === props.session.email) { + if (option.accountID === props.session.accountID) { return; } setParticipants((prevParticipants) => { const newParticipants = _.map(prevParticipants, (participant) => { - if (participant.login === option.login) { + if (participant.accountID === option.accountID) { return {...participant, selected: !participant.selected}; } return participant; @@ -225,7 +225,7 @@ function MoneyRequestConfirmationList(props) { return newParticipants; }); }, - [props.session.email], + [props.session.accountID], ); /** diff --git a/src/components/OptionRow.js b/src/components/OptionRow.js index aa4cde948447..1a8725e592b7 100644 --- a/src/components/OptionRow.js +++ b/src/components/OptionRow.js @@ -135,7 +135,7 @@ class OptionRow extends Component { // We only create tooltips for the first 10 users or so since some reports have hundreds of users, causing performance to degrade. const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips( - (this.props.option.participantsList || this.props.option.login ? [this.props.option] : []).slice(0, 10), + (this.props.option.participantsList || this.props.option.accountID ? [this.props.option] : []).slice(0, 10), isMultipleParticipant, ); let subscriptColor = themeColors.appBG; diff --git a/src/components/OptionsList/BaseOptionsList.js b/src/components/OptionsList/BaseOptionsList.js index df14af5234bd..9c5777e222c9 100644 --- a/src/components/OptionsList/BaseOptionsList.js +++ b/src/components/OptionsList/BaseOptionsList.js @@ -168,7 +168,7 @@ class BaseOptionsList extends Component { hoverStyle={this.props.optionHoveredStyle} optionIsFocused={!this.props.disableFocusOptions && !isDisabled && this.props.focusedIndex === index + section.indexOffset} onSelectRow={this.props.onSelectRow} - isSelected={Boolean(_.find(this.props.selectedOptions, (option) => option.login === item.login))} + isSelected={Boolean(_.find(this.props.selectedOptions, (option) => option.accountID === item.accountID))} showSelectedState={this.props.canSelectMultipleOptions} boldStyle={this.props.boldStyle} isDisabled={isDisabled} diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 9934880eb905..e9e4a2f636a3 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -216,18 +216,19 @@ function isPersonalDetailsReady(personalDetails) { function getParticipantsOptions(report, personalDetails) { const participants = lodashGet(report, 'participantAccountIDs', []); return _.map(getPersonalDetailsForAccountIDs(participants, personalDetails), (details) => ({ - keyForList: details.login, + keyForList: String(details.accountID), login: details.login, accountID: details.accountID, text: details.displayName, firstName: lodashGet(details, 'firstName', ''), lastName: lodashGet(details, 'lastName', ''), - alternateText: Str.isSMSLogin(details.login || '') ? LocalePhoneNumber.formatPhoneNumber(details.login) : details.login, + alternateText: Str.isSMSLogin(details.login || '') ? LocalePhoneNumber.formatPhoneNumber(details.login) : details.login || details.displayName, icons: [ { source: UserUtils.getAvatar(details.avatar, details.accountID), name: details.login, type: CONST.ICON_TYPE_AVATAR, + id: details.accountID, }, ], payPalMeAddress: lodashGet(details, 'payPalMeAddress', ''), @@ -857,12 +858,13 @@ function getSearchOptions(reports, personalDetails, searchValue = '', betas) { function getIOUConfirmationOptionsFromPayeePersonalDetail(personalDetail, amountText) { return { text: personalDetail.displayName ? personalDetail.displayName : personalDetail.login, - alternateText: personalDetail.login, + alternateText: personalDetail.login || personalDetail.displayName, icons: [ { source: UserUtils.getAvatar(personalDetail.avatar, personalDetail.accountID), name: personalDetail.login, type: CONST.ICON_TYPE_AVATAR, + id: personalDetail.accountID, }, ], descriptiveText: amountText, diff --git a/src/pages/iou/MoneyRequestModal.js b/src/pages/iou/MoneyRequestModal.js index 6d3e5e3d19b0..9c3f9b878b50 100644 --- a/src/pages/iou/MoneyRequestModal.js +++ b/src/pages/iou/MoneyRequestModal.js @@ -52,7 +52,7 @@ const propTypes = { }), /** Personal details of all the users */ - personalDetails: PropTypes.shape({ + allPersonalDetails: PropTypes.shape({ /** Primary login of participant */ login: PropTypes.string, @@ -81,7 +81,7 @@ const defaultProps = { currentUserPersonalDetails: { localCurrencyCode: CONST.CURRENCY.USD, }, - personalDetails: {}, + allPersonalDetails: {}, iou: { error: false, selectedCurrencyCode: null, @@ -108,7 +108,7 @@ function MoneyRequestModal(props) { const [selectedOptions, setSelectedOptions] = useState( ReportUtils.isPolicyExpenseChat(props.report) ? OptionsListUtils.getPolicyExpenseReportOptions(props.report) - : OptionsListUtils.getParticipantsOptions(props.report, props.personalDetails), + : OptionsListUtils.getParticipantsOptions(props.report, props.allPersonalDetails), ); const [amount, setAmount] = useState(0); @@ -442,7 +442,7 @@ export default compose( iou: { key: ONYXKEYS.IOU, }, - personalDetails: { + allPersonalDetails: { key: ONYXKEYS.PERSONAL_DETAILS_LIST, }, }),