Preheat oven to 350 degrees.
Boil the green beans in a large pot of salted boiling water for 3 - 5 minutes.
In a large skillet cook the bacon until it is crisp. Remove excess bacon fat that has been rendered, leave approximately 2 - 3 Tbsp of bacon fat rendered in the skillet.
Add the chopped yellow onions, garlic paste, mushrooms and thyme. Cook until fragrant.
Add chilli powder and cayenne pepper (if using).
Add the flour and stir continuously until the flour has absorbed the fat and is no longer raw.
Add the heavy whipping cream to the skillet, continue stirring, and bring to a boil.
Add ¾ c of the gruyere cheese to the skillet.
Add the green beans and stir to combine well.
Transfer everything to a baking sheet that has been sprayed with cooking spray.
Top with remaining ¼ c of gruyere cheese.
Bake until the cheese has melted and the top is bubbly. About 15 - 20 minutes.
Remove from oven when done, top with crispy fried onion straws.