MongoDB find if property in array of objects equals to another field

You can use the $expr operator to compare fields within the same document.

db.collection.find({
  $expr: {
    $in: [
      "$foo.bar",
      "$some_array.xyz"
    ]
  }
})

Working MongoPlayground