Database

db={conversations2:[{"_id":{"$oid":"65c0f64030054c4b8f0481a0"},"otherUserId":{"$numberLong":"45"},"userId":{"$numberLong":"32"},"unreadMessageCount":29},{"_id":{"$oid":"65c0f64030054c4b8f0481a1"},"otherUserId":{"$numberLong":"46"},"userId":{"$numberLong":"32"},"unreadMessageCount":10},{"_id":{"$oid":"65c0f64030054c4b8f0481a2"},"otherUserId":{"$numberLong":"47"},"userId":{"$numberLong":"32"},"unreadMessageCount":0}],user_blocked:[{"_id":{"$oid":"660285eb2be53086024608e6"},"id":{"$numberLong":"45"}},{"_id":{"$oid":"660285eb2be53086024608e7"},"id":{"$numberLong":"555"}}]}

Query

db.conversations2.aggregate([{$match:{userId:32,unreadMessageCount:{$gt:0}}},{/** this will only run once*/$lookup:{from:"user_blocked",pipeline:[{$group:{_id:null,ids:{$addToSet:"$id"}}}],as:"blockedUsers"}},{$set:{blockedUsers:{$first:"$blockedUsers.ids"}}},{$match:{$expr:{$eq:[{$indexOfArray:["$blockedUsers","$otherUserId"]},-1]}}},{$group:{_id:"$userId",unreadMessageCount:{$sum:"$unreadMessageCount"}}}])

Result