01 - Preheat the oven to 400°F. Lightly grease a medium-sized baking dish.
02 - Bring a large pot of salted water to a boil. Cook the pasta until al dente according to package instructions. Drain and set aside.
03 - Heat olive oil and butter in a large skillet over medium heat. Add the chopped onion and cook for 2 to 3 minutes until softened.
04 - Add the sliced mushrooms and cook for 5 to 7 minutes until browned and most liquid has evaporated. Stir in the minced garlic and cook for 1 minute.
05 - Sprinkle the flour over the vegetables and stir well. Gradually whisk in the whole milk to avoid lumps. Add heavy cream, dried thyme, ground nutmeg, salt, and black pepper. Simmer for 3 to 4 minutes until the sauce thickens.
06 - Stir in the fresh spinach and cook until just wilted, about 1 minute.
07 - Remove from heat. Add the cooked pasta and half of both grated mozzarella and Parmesan cheeses to the sauce. Mix thoroughly until combined.
08 - Transfer the mixture to the prepared baking dish. Sprinkle the remaining mozzarella and Parmesan evenly over the top.
09 - Bake in the preheated oven for 20 to 25 minutes until the top is golden brown and bubbling.
10 - Allow the dish to rest for 5 minutes before serving.