Correct conditions for gossip closes #19516 (cherry picked from commit 607686a91267587a05ab6fadc0fce7bc4c93a27b)