Getting the namespace involved in a cross-database $merge stage causes the StringMap<ResolvedNamespace> to store a key for the target collection name with an empty pipeline. But that collection name may also be the name for a collection or view in the database the aggregate command is being run against. For certain pipelines, this may cause a $lookup on a view to instead act as if it were performing the $lookup on an empty collection without erroring.
Note that because LiteParsedPipeline::getInvolvedNamespaces() returns a stdx::unordered_set<NamespaceString> that namespaces may be resolved in different orders across multiple aggregate command executions. And also note that because resolveInvolvedNamespaces() skips resolving a namespace if its collection name already exists in the StringMap, this issue would only manifest if the $merge namespace was resolved before the $lookup namespace.