When doing an aggregate operation with a write stage ($out/$merge), the server selection spec notes:
If there are one or more available servers and one or more of those servers is pre-5.0 (i.e. wire version < 13), drivers MUST NOT use the available read preference and MUST instead select a server using a primary read preference.
Otherwise, if there are either no available servers, all available servers are 5.0+ (i.e. wire version >= 13), or the topology type is LoadBalanced (we can assume the backing mongos is 5.0+), drivers MUST use the available read preference.
However the C driver appears to check if any servers are pre-5.0. This includes unavailable servers, which have ServerType=Unknown and maxWireVersion=0. As a result, if there are not-yet discovered servers, the read preference may be overridden unexpectedly.
Background
This was discovered during implementation of CDRIVER-5706. Using pooled clients for the test "Aggregate with $out includes read preference for 5.0+ server" is more likely to have Unknown servers. Single-threaded clients scan all servers before the first operation. Pooled clients can send operations as soon as there is an eligible server.