Database

db={"courses":[{"_id":1,"name":"Course 1","modules":[{"id":1,"name":"Module 1","lessons":[{"id":1,"name":"Lesson 1"},{"id":2,"name":"Lesson 2"}]}]},{"_id":2,"name":"Course 2","modules":[{"id":1,"name":"Module 1","lessons":[{"id":1,"name":"Lesson 1"},{"id":2,"name":"Lesson 2"}]}]}],"progress":[{"_id":1,"courseId":1,"userId":1,"lessons":[{"id":1,"status":"COMPLETED"}]}]}

Query

db.courses.aggregate([{$match:{"_id":1}},{"$lookup":{"from":"progress","localField":"_id","foreignField":"courseId","pipeline":[{"$match":{"userId":1}},{$project:{lessons:"$lessons"}}],"as":"progress"}},{$unwind:{path:"$progress",preserveNullAndEmptyArrays:true}},{"$unwind":"$modules"},{$set:{"modules.lessons":{$map:{input:"$modules.lessons",as:"moduleLesson",in:{$mergeObjects:["$$moduleLesson",{$first:{$filter:{input:"$progress.lessons",as:"progressLesson",cond:{$eq:["$$moduleLesson.id","$$progressLesson.id"]}}}}]}}}}},{"$project":{"name":1,"modules":1}}])

Result