Brown the mushrooms in batches in olive oil over medium-high heat, 4 to 5 minutes per batch, until golden. Set aside.
Soften the onion in the same skillet, add garlic and thyme, then return the mushrooms and add the wine. Cook until the liquid evaporates; season with salt and pepper.
Make the bechamel: melt the butter, whisk in the flour, cook 1 minute, then slowly whisk in the warm milk. Simmer 5 minutes until thick, then stir in the nutmeg and half the parmesan.
Heat the oven to 375°F. Spread a thin layer of bechamel in a 9x13-inch baking dish.
Layer noodles, one-third of the mushrooms, bechamel, mozzarella and ricotta (plus spinach if using). Repeat twice, finishing with noodles, bechamel, mozzarella and the remaining parmesan.
Cover with foil and bake 25 minutes; uncover and bake 15 to 20 minutes more until golden and bubbling.
Rest 15 minutes before slicing and serving.