Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove expensifySMS domain from the request IOU page #4803

Merged
merged 3 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 CONST from '../../CONST';
Expand Down Expand Up @@ -108,7 +109,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 @@ -269,7 +270,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 @@ -443,7 +443,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 @@ -454,7 +454,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