Preheat your oven to 400°F (200°C) and line a baking sheet with parchment paper.
In a large skillet, heat the olive oil over medium heat. Add the chopped onion and sauté until translucent, about 3-4 minutes.
Add the minced garlic and sliced mushrooms to the skillet. Cook until the mushrooms are browned and any moisture has evaporated, about 5-7 minutes. Stir in the thyme, and season with salt and pepper. Remove from heat and let cool slightly.
On a lightly floured surface, roll out the thawed puff pastry into a rectangle, approximately 12x15 inches.
Place the mushroom mixture in the center of the pastry, leaving about 2 inches of space on each side. Sprinkle the shredded Gruyère cheese over the mushroom mixture.
Cut diagonal slits along the edges of the pastry, about 1 inch apart. Fold the strips over the filling, alternating sides to create a braid effect.
Brush the top of the braid with the beaten egg to give it a golden color when baked.
Bake in the preheated oven for 25-30 minutes, or until the pastry is puffed and golden brown. Allow to cool for a few minutes before slicing.