When signing and encrypting combined GnuPG takes the preferences of the recipient keys into account. This can lead to invalid hash algorithm errors when the preferences of the recipient keys are bad. While this is standard compliant, for a better user experience we could choose the algorithm based on our settings. At least for signing.
This happens for example with OpenPGP certificates created by Greenshield.