diff --git a/backend/controllers/taskController.js b/backend/controllers/taskController.js index 69fd438d..f17f6c78 100644 --- a/backend/controllers/taskController.js +++ b/backend/controllers/taskController.js @@ -329,6 +329,18 @@ export const deleteTask = async (req, res) => { }); } + // Clean up routine task references + await Routine.updateMany( + { userId }, + { + $pull: { + items: { + taskId: taskId, + }, + }, + } + ); + return res.status(200).json({ success: true, message: "Task deleted successfully",