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

Fix/27383: Prevent request money if empty waypoint #27826

Merged
merged 12 commits into from
Sep 25, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
const [headerTitle, setHeaderTitle] = useState();
const transaction = TransactionUtils.getTransaction(iou.transactionID);
DylanDylann marked this conversation as resolved.
Show resolved Hide resolved
const isEmptyWaypoint = _.isEmpty(lodashGet(transaction, 'comment.waypoint.waypoint0', {}));
const shouldNavigateBack = !isDistanceRequest || (isDistanceRequest && isEmptyWaypoint)
DylanDylann marked this conversation as resolved.
Show resolved Hide resolved

useEffect(() => {
if (isDistanceRequest) {
Expand Down Expand Up @@ -91,7 +92,7 @@
// 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 && (!isDistanceRequest || (isDistanceRequest && isEmptyWaypoint)) && !isSplitRequest && !isNewReportIDSelectedLocally.current) {
if (iou.id && shouldNavigateBack && !isSplitRequest && !isNewReportIDSelectedLocally.current) {
navigateBack(true);
}
return;
Expand All @@ -103,14 +104,14 @@
if (shouldReset) {
IOU.resetMoneyRequestInfo(moneyRequestId);
}
if ((!isDistanceRequest || (isDistanceRequest && isEmptyWaypoint)) && ((iou.amount === 0 && !iou.receiptPath) || shouldReset)) {
if (shouldNavigateBack && ((iou.amount === 0 && !iou.receiptPath) || shouldReset)) {
navigateBack(true);
}

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

Check warning on line 114 in src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'shouldNavigateBack'. Either include it or remove the dependency array

return (
<ScreenWrapper
Expand Down
Loading