The query
db.coll.aggregate([{$lookup: {from: "other", let: {role: "$role"}, pipeline:[{$match:{$expr: {$eq:["$role", "$$USER_ROLES.role"]}}}], as: "out"}}])
fails with the error "PlanExecutor error during aggregation :: caused by :: error while multiplanner was selecting best plan :: caused by :: Builtin variable '$$USER_ROLES' is not available" (code 51144).
Given that the query
db.other.aggregate([{$match: {$expr: {$eq: ["$role", "$$USER_ROLES.role"]}}}])
succeeds and behaves as anticipated, I suspect this is due to $$USER_ROLES not being set properly for a sub-pipeline.