You're welcome! Actually I didn't ever understand if this is an unresolved bug or an expected behavior. Anyway, it is reported in the openssh FAQ, here
and involves non-interactive shells.
Indeed, if you need to receive some output from the remote .bashrc upon login sessions, you can do something similar to your original script: just exit if non-interactive OR don't send output OR invert the logic, e.g.
if [ -n "$PS1" ]
Moreover, non-interactive bash sessions don't execute .bash_profile, so that it is a good place for echoing
messages or executing commands that write to standard output.