Do not show in composer legend unused layers if filtering by map is enabled

This resolves #11457 and partially #11293