For details, see T404118#11195674 and following comments. In short, it does the comparison $this->dbLoadBalancerFactory->getLocalDomainID() === $wikiId, but the LocalDomainID is encoded such that hyphen are replaced away, and thus it won't match a wiki ID obtained from, for example, WikiMap::getCurrentWikiID.
It looks like the fix would be to use WikiMap::getCurrentWikiID instead of getLocalDomainID, but this doesn't help with the fact that there seems to be confusion between wiki IDs and DB domains.
This pattern is used in at least 5 places (UserGroupManagerFactory, BlockRestrictionStoreFactory, DatabaseBlockStoreFactory, ActorStoreFactory, UserFactory).