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