01 - Preheat oven to 375°F. Lightly grease a 9x13-inch baking dish.
02 - In a large skillet, heat olive oil over medium heat. Add onion and cook until softened, about 3 minutes. Add garlic and sauté for 1 additional minute until fragrant.
03 - Add chopped spinach to the skillet and cook until wilted, about 2 minutes. Remove from heat and set aside.
04 - In a large mixing bowl, combine cream cheese and sour cream. Stir until smooth and well blended.
05 - Fold in cooked chicken, chopped artichokes, spinach mixture, half of the mozzarella, Parmesan, oregano, basil, salt, pepper, and red pepper flakes if using. Mix until evenly incorporated.
06 - Transfer mixture to the prepared baking dish and spread into an even layer. Sprinkle remaining mozzarella evenly over the top.
07 - Bake uncovered for 30 minutes, or until the edges are bubbling and the top is golden brown.
08 - Remove from oven and let rest for 5 minutes before serving to allow the filling to set.