Skip to content

Commit 091051f

Browse files
MelvinBotEskalifer1
andcommitted
Move resetSplitShares below no-op guard in edit flow
Prevent no-op edits from wiping custom split shares by moving resetSplitShares after the unchanged-amount early return. For non-editing flows it still runs before navigation as before. Co-authored-by: Eskalifer1 <Eskalifer1@users.noreply.github.com>
1 parent a6cf436 commit 091051f

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/pages/iou/request/step/IOURequestStepAmount.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -397,12 +397,11 @@ function IOURequestStepAmount({
397397
const saveAmountAndCurrency = ({amount, paymentMethod}: AmountParams) => {
398398
const newAmount = convertToBackendAmount(Number.parseFloat(amount));
399399

400-
// Edits to the amount from the splits page should reset the split shares.
401-
if (transaction?.splitShares) {
402-
resetSplitShares(transaction, newAmount, selectedCurrency, !isEditing);
403-
}
404-
405400
if (!isEditing) {
401+
// Edits to the amount from the splits page should reset the split shares.
402+
if (transaction?.splitShares) {
403+
resetSplitShares(transaction, newAmount, selectedCurrency, true);
404+
}
406405
navigateToNextPage({amount, paymentMethod});
407406
return;
408407
}
@@ -414,6 +413,11 @@ function IOURequestStepAmount({
414413
return;
415414
}
416415

416+
// Edits to the amount from the splits page should reset the split shares (only when the amount actually changed).
417+
if (transaction?.splitShares) {
418+
resetSplitShares(transaction, newAmount, selectedCurrency, false);
419+
}
420+
417421
// If currency has changed, then we get the default tax rate based on currency, otherwise we use the current tax rate selected in transaction, if we have it.
418422
const transactionTaxCode = getTransactionDetails(currentTransaction)?.taxCode;
419423
const defaultTaxCode = getDefaultTaxCode(policy, currentTransaction, selectedCurrency) ?? '';

0 commit comments

Comments
 (0)