Preheat your oven to 375 degrees F (190 degrees C). Lightly grease a 9x13 inch baking dish.
Cook the onions. In a large skillet, heat the olive oil over medium heat. Add the sliced onions and cook, stirring occasionally, for about 8 to 10 minutes until they are soft and lightly caramelized.
Brown the beef. Add the ground beef to the skillet with the onions.
Cook, breaking it up with a spoon, until it is no longer pink, about 5 to 7 minutes. Drain any excess fat if needed.
Add garlic and seasonings. Stir in the minced garlic and cook for 1 minute until fragrant. Sprinkle the flour over the mixture and stir to coat.
Cook for 1 minute more.
Make the sauce. Slowly pour in the beef broth while stirring. Add the Worcestershire sauce, dried thyme, salt, and pepper. Bring to a gentle simmer, then cook for 2 to 3 minutes until the sauce thickens slightly.
Remove from heat.
Layer the dish. Spread half of the sliced potatoes evenly in the bottom of the prepared baking dish. Pour half of the beef and onion mixture over the potatoes. Repeat with the remaining potatoes and then the remaining beef mixture.
Add cheese and bake. Sprinkle the Gruyere and mozzarella cheeses evenly over the top.
Cover the dish tightly with foil and bake for 40 minutes.
Finish baking. Remove the foil and bake for another 20 to 25 minutes, until the potatoes are tender when pierced with a fork and the cheese is bubbly and golden brown.
Rest and serve. Let the dish rest for 5 to 10 minutes before serving. Garnish with fresh parsley if desired.