Just writing down some thoughts on this.
I find it quite counter-intuitive that if you have a 1 BTC output and make a transaction spending 0.01 BTC and sending 0.99 BTC back to yourself in change, that unless that transaction is in your mempool, your balance drops from 1 to 0. Unconfirmed change in the mempool appears in available balance (assuming we can spend 0-conf change), but if it is not in the mempool it is not reflected at all, but the output spent in the transaction is still spent.
This can occur because walletbroadcast=0 and you’re delaying broadcast or using another broadcast method or because the initial transaction was evicted. In either case though it doesn’t make sense to count the entire input as spent but not credit the change output.
I believe it would make sense to include the unconfirmed non-mempool change in the pending balance.
Unfortunately this is non-trivial. This can best be seen by the example of two transactions in the wallet that spend the same input. Naively you’d double count the change, which is clearly wrong. It’s non-obvious which change you should count nor how you would go about implementing that if you did have a plan. One idea would be if you had a mempool package acceptance test (ala @sdaftuar) you could try to add all non-mempooled wallet transactions incrementally in time order, and take the resulting putative mempool state as what would count. But its starting to get a bit cumbersome. Another idea would be to check the unconfirmed non-mempool change for potential conflicts and only count the smallest change.
There are other aspects of trickiness such as mixed debit transactions.