Stumbled upon this tiny bug. This has been working by accident.
The comparison is evaluated first, so total_amount ends up holding a boolean instead of the actual amount.
It can be verified by adding the value to the returned error message and running the wallet_create_tx.py
test.
Note:
I assume something like -Wparentheses in CI (or similar) should help us catching similar issues elsewhere.