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: Search - RHP closes or returns to transaction thread depending on which field is edited. #44662

Merged
merged 7 commits into from
Jul 12, 2024
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
3 changes: 1 addition & 2 deletions src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,14 @@ function MoneyRequestView({
merchantTitle = translate('iou.receiptStatusTitle');
amountTitle = translate('iou.receiptStatusTitle');
}

const saveBillable = useCallback(
(newBillable: boolean) => {
// If the value hasn't changed, don't request to save changes on the server and just close the modal
if (newBillable === TransactionUtils.getBillable(transaction)) {
Navigation.dismissModal();
return;
}
IOU.updateMoneyRequestBillable(transaction?.transactionID ?? '-1', report?.reportID, newBillable, policy, policyTagList, policyCategories);
Navigation.dismissModal();
},
[transaction, report, policy, policyTagList, policyCategories],
);
Expand Down
11 changes: 3 additions & 8 deletions src/pages/iou/request/step/IOURequestStepAmount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,7 @@ function IOURequestStepAmount({
// If the value hasn't changed, don't request to save changes on the server and just close the modal
const transactionCurrency = TransactionUtils.getCurrency(currentTransaction);
if (newAmount === TransactionUtils.getAmount(currentTransaction) && currency === transactionCurrency) {
if (isSplitBill) {
Navigation.goBack(backTo);
} else {
Navigation.dismissModal();
}

navigateBack();
return;
}

Expand All @@ -298,12 +293,12 @@ function IOURequestStepAmount({

if (isSplitBill) {
IOU.setDraftSplitTransaction(transactionID, {amount: newAmount, currency, taxCode, taxAmount});
Navigation.goBack(backTo);
navigateBack();
return;
}

IOU.updateMoneyRequestAmountAndCurrency({transactionID, transactionThreadReportID: reportID, currency, amount: newAmount, taxAmount, policy, taxCode});
Navigation.dismissModal();
navigateBack();
};

return (
Expand Down
9 changes: 5 additions & 4 deletions src/pages/iou/request/step/IOURequestStepDistance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ function IOURequestStepDistance({
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, []);

const navigateBack = () => {
const navigateBack = useCallback(() => {
Navigation.goBack(backTo);
};
}, [backTo]);

/**
* Takes the user to the page for editing a specific waypoint
Expand Down Expand Up @@ -379,7 +379,7 @@ function IOURequestStepDistance({
const addresses = Object.fromEntries(Object.entries(waypoints).map(([key, waypoint]) => [key, 'address' in waypoint ? waypoint.address : {}]));
const hasRouteChanged = !isEqual(transactionBackup?.routes, transaction?.routes);
if (isEqual(oldAddresses, addresses)) {
Navigation.dismissModal();
navigateBack();
return;
}
IOU.updateMoneyRequestDistance({
Expand All @@ -389,12 +389,13 @@ function IOURequestStepDistance({
...(hasRouteChanged ? {routes: transaction?.routes} : {}),
policy,
});
Navigation.dismissModal();
navigateBack();
return;
}

navigateToNextStep();
}, [
navigateBack,
duplicateWaypointsError,
atLeastTwoDifferentWaypointsError,
hasRouteError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ function IOURequestStepScan({

const updateScanAndNavigate = useCallback(
(file: FileObject, source: string) => {
Navigation.dismissModal();
navigateBack();
IOU.replaceReceipt(transactionID, file as File, source);
},
[transactionID],
Expand Down
8 changes: 4 additions & 4 deletions src/pages/iou/request/step/IOURequestStepScan/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ function IOURequestStepScan({
});
}

const navigateBack = () => {
const navigateBack = useCallback(() => {
Navigation.goBack(backTo);
};
}, [backTo]);

const navigateToParticipantPage = useCallback(() => {
switch (iouType) {
Expand Down Expand Up @@ -417,9 +417,9 @@ function IOURequestStepScan({
const updateScanAndNavigate = useCallback(
(file: FileObject, source: string) => {
IOU.replaceReceipt(transactionID, file as File, source);
Navigation.dismissModal();
navigateBack();
},
[transactionID],
[transactionID, navigateBack],
);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/pages/iou/request/step/IOURequestStepTag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function IOURequestStepTag({
}
if (isEditing) {
IOU.updateMoneyRequestTag(transactionID, report?.reportID ?? '-1', updatedTag, policy, policyTags, policyCategories);
Navigation.dismissModal();
navigateBack();
return;
}
IOU.setMoneyRequestTag(transactionID, updatedTag);
Expand Down
Loading