Skip to content

Commit

Permalink
Merge pull request #4803 from parasharrajat/iou-fix
Browse files Browse the repository at this point in the history
Remove expensifySMS domain from the request IOU page
  • Loading branch information
Julesssss authored Aug 31, 2021
2 parents 02d3e39 + c194a29 commit d5b7eb3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/components/IOUConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -225,15 +226,15 @@ 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
amount: this.calculateAmount(selectedParticipants),
}));

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
Expand Down
7 changes: 3 additions & 4 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function getPersonalDetailsForLogins(logins, personalDetails) {

if (!personalDetail) {
personalDetail = {
login: addSMSDomainIfPhoneNumber(login),
login,
displayName: login,
avatar: getDefaultAvatar(login),
};
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/pages/iou/IOUModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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,
}));
Expand Down Expand Up @@ -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),
});
}

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/OptionsListUtilsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down

0 comments on commit d5b7eb3

Please sign in to comment.