Skip to content

Commit

Permalink
Revert "Fix/27383: Prevent request money if empty waypoint"
Browse files Browse the repository at this point in the history
  • Loading branch information
roryabraham authored Sep 26, 2023
1 parent fc0e330 commit e35210b
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import * as IOU from '../../../../libs/actions/IOU';
import * as MoneyRequestUtils from '../../../../libs/MoneyRequestUtils';
import {iouPropTypes, iouDefaultProps} from '../../propTypes';
import useLocalize from '../../../../hooks/useLocalize';
import * as TransactionUtils from '../../../../libs/TransactionUtils';

const propTypes = {
/** React Navigation route */
Expand Down Expand Up @@ -54,8 +53,7 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route}) {
const isScanRequest = MoneyRequestUtils.isScanRequest(selectedTab);
const isSplitRequest = iou.id === CONST.IOU.MONEY_REQUEST_TYPE.SPLIT;
const [headerTitle, setHeaderTitle] = useState();
const transaction = TransactionUtils.getTransaction(iou.transactionID);
const isEmptyWaypoint = _.isEmpty(lodashGet(transaction, 'comment.waypoint.waypoint0', {}));

useEffect(() => {
if (isDistanceRequest) {
setHeaderTitle(translate('common.distance'));
Expand Down Expand Up @@ -87,12 +85,10 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route}) {
};

useEffect(() => {
const isInvalidDistanceRequest = !isDistanceRequest || isEmptyWaypoint;

// ID in Onyx could change by initiating a new request in a separate browser tab or completing a request
if (prevMoneyRequestId.current !== iou.id) {
// The ID is cleared on completing a request. In that case, we will do nothing
if (iou.id && isInvalidDistanceRequest && !isSplitRequest && !isNewReportIDSelectedLocally.current) {
if (iou.id && !isDistanceRequest && !isSplitRequest && !isNewReportIDSelectedLocally.current) {
navigateBack(true);
}
return;
Expand All @@ -104,14 +100,14 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route}) {
if (shouldReset) {
IOU.resetMoneyRequestInfo(moneyRequestId);
}
if (isInvalidDistanceRequest && ((iou.amount === 0 && !iou.receiptPath) || shouldReset)) {
if (!isDistanceRequest && ((iou.amount === 0 && !iou.receiptPath) || shouldReset)) {
navigateBack(true);
}

return () => {
prevMoneyRequestId.current = iou.id;
};
}, [iou.amount, iou.id, iou.receiptPath, isDistanceRequest, isSplitRequest, isEmptyWaypoint]);
}, [iou.amount, iou.id, iou.receiptPath, isDistanceRequest, isSplitRequest]);

return (
<ScreenWrapper
Expand Down

0 comments on commit e35210b

Please sign in to comment.