Set oven temperature to 375°F.
Heat up a big saucepan of water until it boils. After it comes to a boil, add the green beans and simmer for three minutes. To end the cooking process, quickly drain the green beans and transfer them to a dish with ice and cold water. After cooling down, remove the green beans and reserve.
Add the butter to a large pan set over medium heat. After it has melted, add the garlic and mushrooms and sauté for three to four minutes, or until the mushrooms are soft and starting to turn golden.
Then add the flour and whisk until the flour is largely dissolved and properly blended. Stir thoroughly to mix in the chicken broth gradually, being sure to get into any hidden pockets of flour. Scrape off any browned parts from the pan's bottom with a wooden tool.
Add the ground nutmeg, ground pepper, red pepper flakes (if using), lemon juice, dijon mustard, Worcestershire sauce, thyme, and salt/pepper to taste. Stir thoroughly to mix. Simmer this mixture for two to three minutes.
Next, add the cream (or half-and-half) and half of the parmesan, and mix for one to two minutes, or until everything is thoroughly combined.
After blanching the green beans, transfer them to an ovenproof casserole dish, cover with the creamy mushroom sauce, and toss to coat thoroughly. Sprinkle the remaining parmesan cheese evenly on top of the green bean mixture.
After transferring the dish to the oven, bake it for twenty minutes.
Take out of the oven and stir the mixture again. Scatter the fried shallots evenly on top of the green beans. Re-enter the oven and bake for a further 7 to 10 minutes, being cautious not to burn.
This green bean dish should be served right away. Have fun!