diff --git a/src/components/IOUConfirmationList.js b/src/components/IOUConfirmationList.js index 3be35546855a..b3e946a3f347 100755 --- a/src/components/IOUConfirmationList.js +++ b/src/components/IOUConfirmationList.js @@ -8,6 +8,7 @@ import styles from '../styles/styles'; import Text from './Text'; import themeColors from '../styles/themes/default'; import { + addSMSDomainIfPhoneNumber, getIOUConfirmationOptionsFromMyPersonalDetail, getIOUConfirmationOptionsFromParticipants, } from '../libs/OptionsListUtils'; @@ -225,7 +226,7 @@ class IOUConfirmationList extends Component { } const selectedParticipants = this.getSelectedParticipants(); const splits = _.map(selectedParticipants, participant => ({ - email: participant.login, + email: addSMSDomainIfPhoneNumber(participant.login), // We should send in cents to API // Cents is temporary and there must be support for other currencies in the future @@ -233,7 +234,7 @@ class IOUConfirmationList extends Component { })); splits.push({ - email: this.props.myPersonalDetails.login, + email: addSMSDomainIfPhoneNumber(this.props.myPersonalDetails.login), // The user is default and we should send in cents to API // USD is temporary and there must be support for other currencies in the future diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 4123ef8e0ae7..7e7c38188cd9 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -106,7 +106,7 @@ function getPersonalDetailsForLogins(logins, personalDetails) { if (!personalDetail) { personalDetail = { - login: addSMSDomainIfPhoneNumber(login), + login, displayName: login, avatar: getDefaultAvatar(login), }; @@ -239,8 +239,7 @@ function createOption(personalDetailList, report, draftComments, { // It doesn't make sense to provide a login in the case of a report with multiple participants since // there isn't any one single login to refer to for a report. - // If single login is a mobile number, appending SMS domain - login: !hasMultipleParticipants ? addSMSDomainIfPhoneNumber(personalDetail.login) : null, + login: !hasMultipleParticipants ? personalDetail.login : null, reportID: report ? report.reportID : null, isUnread: report ? report.unreadActionCount > 0 : null, hasDraftComment: _.size(reportDraftComment) > 0, @@ -289,7 +288,7 @@ function isCurrentUser(userDetails) { return false; } - // If user login is mobile number, append sms domain if not appended already just a fail safe. + // If user login is mobile number, append sms domain if not appended already. const userDetailsLogin = addSMSDomainIfPhoneNumber(userDetails.login); // Initial check with currentUserLogin diff --git a/src/pages/iou/IOUModal.js b/src/pages/iou/IOUModal.js index 1fd560f46fb5..f71ce27f4d88 100755 --- a/src/pages/iou/IOUModal.js +++ b/src/pages/iou/IOUModal.js @@ -3,6 +3,7 @@ import {View, TouchableOpacity} from 'react-native'; import PropTypes from 'prop-types'; import lodashGet from 'lodash/get'; import {withOnyx} from 'react-native-onyx'; +import Str from 'expensify-common/lib/str'; import IOUAmountPage from './steps/IOUAmountPage'; import IOUParticipantsPage from './steps/IOUParticipantsPage'; import IOUConfirmPage from './steps/IOUConfirmPage'; @@ -17,7 +18,7 @@ import Navigation from '../../libs/Navigation/Navigation'; import ONYXKEYS from '../../ONYXKEYS'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import compose from '../../libs/compose'; -import {getPersonalDetailsForLogins} from '../../libs/OptionsListUtils'; +import {addSMSDomainIfPhoneNumber, getPersonalDetailsForLogins} from '../../libs/OptionsListUtils'; import FullScreenLoadingIndicator from '../../components/FullscreenLoadingIndicator'; import ScreenWrapper from '../../components/ScreenWrapper'; import Tooltip from '../../components/Tooltip'; @@ -109,7 +110,7 @@ class IOUModal extends Component { .map(personalDetails => ({ login: personalDetails.login, text: personalDetails.displayName, - alternateText: personalDetails.login, + alternateText: Str.isSMSLogin(personalDetails.login) ? Str.removeSMSDomain(personalDetails.login) : personalDetails.login, icons: [personalDetails.avatar], keyForList: personalDetails.login, })); @@ -270,7 +271,7 @@ class IOUModal extends Component { // should send in cents to API amount: Math.round(this.state.amount * 100), currency: this.props.iou.selectedCurrencyCode, - debtorEmail: this.state.participants[0].login, + debtorEmail: addSMSDomainIfPhoneNumber(this.state.participants[0].login), }); } diff --git a/tests/unit/OptionsListUtilsTest.js b/tests/unit/OptionsListUtilsTest.js index 0a16c61e642b..0bdcea4ca963 100644 --- a/tests/unit/OptionsListUtilsTest.js +++ b/tests/unit/OptionsListUtilsTest.js @@ -445,7 +445,7 @@ describe('OptionsListUtils', () => { expect(results.recentReports.length).toBe(0); expect(results.personalDetails.length).toBe(0); expect(results.userToInvite).not.toBe(null); - expect(results.userToInvite.login).toBe(`+15005550006${CONST.SMS.DOMAIN}`); + expect(results.userToInvite.login).toBe('+15005550006'); // When we add a search term for which no options exist and the searchValue itself // is a potential phone number with country code added @@ -456,7 +456,7 @@ describe('OptionsListUtils', () => { expect(results.recentReports.length).toBe(0); expect(results.personalDetails.length).toBe(0); expect(results.userToInvite).not.toBe(null); - expect(results.userToInvite.login).toBe(`+15005550006${CONST.SMS.DOMAIN}`); + expect(results.userToInvite.login).toBe('+15005550006'); // Test Concierge's existence in new group options results = OptionsListUtils.getNewGroupOptions(REPORTS_WITH_CONCIERGE, PERSONAL_DETAILS_WITH_CONCIERGE);