'retrieve nested data from mongodb record depend on condition

I have a board record like this

{
_id:"6257d2edfbc4d4d1d53bb7b8"
tasks:["624acd4fce5fbb5ce20ddb88","624acd68ce5fbb5ce20de3b5"]
}

This is my tasks collection

[
  {
    _id:"624acd4fce5fbb5ce20ddb88",
    status:"inProgress"
  },
  {
    _id:"624acd68ce5fbb5ce20de3b5"
    status:"done"
  }
]

I am trying to retrieve the board data and the count of inProgress tasks and done tasks in aggregate like this but it show me this error

input to $filter must be an array not object
Board.aggregate([
        {
          $facet: {
            totalDocs: [{ $match: { $and: [data] } }],
            totalInProgress: [
              {
                $lookup: {
                  from: "tasks",
                  localField: "tasks",
                  foreignField: "_id",
                  as: "tasks",
                },
              },
              { $unwind: { path: "$tasks", preserveNullAndEmptyArrays: true } },
              {
                $project: {
                  tasks: {
                    $filter: {
                      input: "$tasks",
                      as: "task",
                      cond: { $eq: ["$$task.status", "inProgress"] },
                    },
                  },
                },
              },
            ],
          },
        },
      ]);


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source