Database

db={"collection":[{"_id":"5d8051cdf0b1017da7bff23c","description":"<p>will update soon</p>","topic":"How to setup Kafka Cluster on CentOS","comments":[{"created_at":"2019-10-12T02:13:01.859Z","updated_at":"2019-10-12T02:13:01.859Z","edited":false,"_id":"5da182aa013d12567e340a2d","message":"test","replies":[{"created_at":"2019-10-12T02:13:01.859Z","updated_at":"2019-10-12T02:13:01.859Z","edited":false,"_id":"5da182aa013d12567e340a2a","message":"I am replying to first comment","commentator":"5daae8b8af029ec4533fe317"},{"created_at":"2019-10-12T02:13:01.859Z","updated_at":"2019-10-12T02:13:01.859Z","edited":false,"_id":"5da182aa013d12567e340a2c","message":"Helpful second Comment","commentator":"5d7f936544dac213e3f650ec"}]},{"created_at":"2019-10-13T02:13:01.859Z","updated_at":"2019-10-13T02:13:01.859Z","edited":false,"_id":"5da182aa013d12567e340a2d","message":"test","replies":[{"_id":"5da182aa013d12567e340a2b","created_at":"2019-10-13T02:13:01.859Z","updated_at":"2019-10-13T02:13:01.859Z","edited":false,"message":"I am replying to first comment","commentator":"5daae8b8af029ec4533fe318"},{"_id":"5da182aa013d12567e340a2d","created_at":"2019-10-13T02:13:01.859Z","updated_at":"2019-10-13T02:13:01.859Z","edited":false,"message":"Helpful second Comment","commentator":"5d7f936544dac213e3f650ed"}]}]}],"users":[{"_id":"5daae8b8af029ec4533fe317","first_name":"test","last_name":"test"},{_id:"5d7f936544dac213e3f650ec","first_name":"test2","last_name":"test2"},{_id:"5daae8b8af029ec4533fe318","first_name":"test3","last_name":"test3"},{_id:"5d7f936544dac213e3f650ed","first_name":"test4","last_name":"test4"}]}

Query

db.collection.aggregate([{$lookup:{from:"users",let:{thread_reply_commentator:{$reduce:{input:"$comments.replies.commentator",initialValue:[],in:{$concatArrays:["$$value","$$this"]}}}},pipeline:[{$match:{$expr:{$in:["$_id","$$thread_reply_commentator"]}}}],as:"comentators"}},{$addFields:{comments:{$map:{input:"$comments",as:"comments",in:{$mergeObjects:["$$comments",{replies:{$map:{input:"$$comments.replies",as:"replies",in:{$mergeObjects:["$$replies",{commentator:{$arrayElemAt:[{$filter:{input:"$comentators",cond:{$eq:["$$this._id","$$replies.commentator"]}}},0]}}]}}}}]}}}}},{$project:{comentators:0,"comments.replies.commentator._id":0}}])

Result