diff --git a/packages/desktop-client/src/components/modals/CloseAccountModal.tsx b/packages/desktop-client/src/components/modals/CloseAccountModal.tsx index e7e8de8d2f..eb98d62448 100644 --- a/packages/desktop-client/src/components/modals/CloseAccountModal.tsx +++ b/packages/desktop-client/src/components/modals/CloseAccountModal.tsx @@ -91,24 +91,27 @@ export function CloseAccountModal({ const onSubmit = (event: FormEvent) => { event.preventDefault(); - const transferError = balance !== 0 && transferAccountId === ''; + const transferError = balance !== 0 && !transferAccountId; setTransferError(transferError); const categoryError = - needsCategory(account, transferAccountId, accounts) && categoryId === ''; + needsCategory(account, transferAccountId, accounts) && !categoryId; setCategoryError(categoryError); - if (!transferError && !categoryError) { - setLoading(true); - - dispatch( - closeAccount({ - id: account.id, - transferAccountId: transferAccountId || null, - categoryId: categoryId || null, - }), - ); + if (transferError || categoryError) { + return false; } + + setLoading(true); + + dispatch( + closeAccount({ + id: account.id, + transferAccountId: transferAccountId || null, + categoryId: categoryId || null, + }), + ); + return true; }; return ( @@ -150,8 +153,9 @@ export function CloseAccountModal({
{ - onSubmit(e); - close(); + if (onSubmit(e)) { + close(); + } }} > {balance !== 0 && ( diff --git a/upcoming-release-notes/4769.md b/upcoming-release-notes/4769.md new file mode 100644 index 0000000000..c2138b85ad --- /dev/null +++ b/upcoming-release-notes/4769.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [alecbakholdin] +--- + +Fixed issue with close account flow not properly validating transfer or category