Skip to content

A local-first personal finance app

Fixes Issue 495 Transfer allowed from same account (#902)

biohzrddd19a8f14ad9ab
diff --git a/packages/desktop-client/src/components/accounts/TransactionsTable.js b/packages/desktop-client/src/components/accounts/TransactionsTable.js
index 37f5206182..81b92b7f08 100644
--- a/packages/desktop-client/src/components/accounts/TransactionsTable.js
+++ b/packages/desktop-client/src/components/accounts/TransactionsTable.js
@@ -379,6 +379,7 @@ function StatusCell({
function PayeeCell({
id,
payeeId,
+ accountId,
focused,
inherited,
payees,
@@ -396,6 +397,9 @@ function PayeeCell({
const isNewAutocompleteEnabled = useFeatureFlag('newAutocomplete');
let isCreatingPayee = useRef(false);
+ // Filter out the account we're currently in as it is not a valid transfer
+ accounts = accounts.filter(account => account.id !== accountId);
+
return (
<CustomCell
width="flex"
@@ -786,6 +790,7 @@ export const Transaction = React.memo(function Transaction(props) {
<PayeeCell
id={id}
payeeId={payeeId}
+ accountId={accountId}
focused={focusedField === 'payee'}
inherited={inheritedFields && inheritedFields.has('payee')}
payees={payees}
diff --git a/packages/desktop-client/src/components/autocomplete/NewPayeeAutocomplete.js b/packages/desktop-client/src/components/autocomplete/NewPayeeAutocomplete.js
index 888217e6cf..6c4f31c8ca 100644
--- a/packages/desktop-client/src/components/autocomplete/NewPayeeAutocomplete.js
+++ b/packages/desktop-client/src/components/autocomplete/NewPayeeAutocomplete.js
@@ -3,8 +3,6 @@ import { useDispatch } from 'react-redux';
import { components as SelectComponents } from 'react-select';
import { createPayee } from 'loot-core/src/client/actions/queries';
-import { useCachedAccounts } from 'loot-core/src/client/data-hooks/accounts';
-import { useCachedPayees } from 'loot-core/src/client/data-hooks/payees';
import { getActivePayees } from 'loot-core/src/client/reducers/queries';
import Add from '../../icons/v1/Add';
@@ -51,6 +49,8 @@ function MenuListWithFooter(props) {
}
export default function PayeeAutocomplete({
+ payees,
+ accounts,
value,
multi = false,
showMakeTransfer = true,
@@ -60,9 +60,6 @@ export default function PayeeAutocomplete({
onManagePayees,
...props
}) {
- const payees = useCachedPayees();
- const accounts = useCachedAccounts();
-
const [focusTransferPayees, setFocusTransferPayees] = useState(
defaultFocusTransferPayees,
);
diff --git a/upcoming-release-notes/902.md b/upcoming-release-notes/902.md
new file mode 100644
index 0000000000..ff004d0a47
--- /dev/null
+++ b/upcoming-release-notes/902.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [biohzrddd]
+---
+
+Remove currently viewed account from list of possible transfer accounts