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

Filter out accounts we don't have login yet #21290

Closed
Closed
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
9 changes: 9 additions & 0 deletions src/pages/iou/steps/MoneyRequestAmountPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import BigNumberPad from '../../../components/BigNumberPad';
import Navigation from '../../../libs/Navigation/Navigation';
import ROUTES from '../../../ROUTES';
import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize';
import personalDetailsPropType from '../../personalDetailsPropType';
import compose from '../../../libs/compose';
import * as ReportUtils from '../../../libs/ReportUtils';
import * as IOUUtils from '../../../libs/IOUUtils';
Expand Down Expand Up @@ -53,6 +54,9 @@ const propTypes = {
),
}),

/** The personal details of the person who is logged in */
personalDetails: personalDetailsPropType,

...withLocalizePropTypes,
...withCurrentUserPersonalDetailsPropTypes,
};
Expand All @@ -65,6 +69,7 @@ const defaultProps = {
},
},
report: {},
personalDetails: {},
iou: {
id: '',
amount: 0,
Expand Down Expand Up @@ -426,6 +431,7 @@ class MoneyRequestAmountPage extends React.Component {
? [{reportID: this.props.report.reportID, isPolicyExpenseChat: true, selected: true}]
: _.chain(this.props.report.participantAccountIDs)
.filter((accountID) => currentUserAccountID !== accountID)
.filter((accountID) => lodashGet(this.props.personalDetails, `${accountID}.login`))
.map((accountID) => ({accountID, selected: true}))
.value();
IOU.setMoneyRequestParticipants(participants);
Expand Down Expand Up @@ -517,5 +523,8 @@ export default compose(
report: {
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${lodashGet(route, 'params.reportID', '')}`,
},
personalDetails: {
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
},
}),
)(MoneyRequestAmountPage);
9 changes: 7 additions & 2 deletions src/pages/iou/steps/MoneyRequestConfirmPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,15 @@ function MoneyRequestConfirmPage(props) {
const createTransaction = useCallback(
(selectedParticipants) => {
const trimmedComment = props.iou.comment.trim();

const splitReport = ReportUtils.getChatByParticipants(_.map(selectedParticipants, (participant) => Number(participant.accountID)));
// IOUs created from a group report will have a reportID param in the route.
// Since the user is already viewing the report, we don't need to navigate them to the report
if (iouType.current === CONST.IOU.MONEY_REQUEST_TYPE.SPLIT && CONST.REGEX.NUMBER.test(reportID.current)) {
if (
iouType.current === CONST.IOU.MONEY_REQUEST_TYPE.SPLIT &&
CONST.REGEX.NUMBER.test(reportID.current) &&
splitReport !== undefined &&
splitReport.reportID === reportID.current
) {
IOU.splitBill(
selectedParticipants,
props.currentUserPersonalDetails.login,
Expand Down