Melt butter in a frying pan over medium-high heat. Add onion, garlic and thyme. Cook for 30 seconds. Add mushrooms and red pepper flakes, then season with salt and pepper and sauté for 8 minutes.
Stir in spinach (a handful at a time, allowing to wilt before adding the next handful), and cook for an additional 2 minutes or until spinach wilts. Set aside.
In a small saucepan, combine all sauce ingredients. Heat on low, stirring occasionally, until cheese melts and the sauce becomes smooth and homogeneous.
In a casserole dish, arrange a layer of shredded chicken meat. Spread over half of the cheesy sauce then arrange a layer of mushroom-spinach mixture. Spread remaining sauce on top, sprinkle with mozzarella and bake for 20 minutes or until browned and bubbly on top.