Preheat oven to 375°F.: The heat should feel steady and even when the oven light goes on, with the rack positioned in the center to allow for uniform browning. Preheating ensures the casserole starts cooking immediately when it goes in, which helps the sauce bubble and the topping crisp. A common mistake is sliding the dish into a not fully heated oven, which can lead to uneven cooking and a soggy topping. If your oven runs hot or cold, use an oven thermometer to confirm the temperature.
Bring a large pot of water to boil and salt generously. Add green beans and cook until bright green, about 3 to 4 minutes.: You want the water to roar at a steady boil so the beans cook quickly and evenly, retaining their vivid color and firm snap. Salting the water seasons the beans from the inside out. Listen for a gentle, rolling boil and watch for the beans to turn vibrant green, which signals they are done. Overcooking here will leave them limp and forgettable, so set a timer and test by tasting one for the right tender crispness.
Transfer the green beans to an ice bath (just a large bowl of cold water and ice) and let sit for 3 minutes. Drain well and set aside. This may need to be done in batches depending on the size of your pot. (Pro tip: Place the green beans in a salad spinner to get rid of more water.): The ice bath stops the cooking instantly, locking in color and texture. You should hear a faint clinking as the beans hit the cold water, and after draining they should snap when bent. Using a salad spinner is a brilliant shortcut to remove excess water, which helps the sauce cling rather than slide off. A common error is skipping this step, which often leads to overcooked, dull beans.
Meanwhile, in a large, deep skillet, heat the olive oil over medium heat. Add the chopped onions and cook until translucent, about 5 to 7 minutes.: The pan should shimmer gently when the oil is ready, and the onions will soften and give off a sweet aroma as they turn translucent. Stir occasionally to prevent any edges from browning too quickly. The goal is a gentle sweat so the natural sugars come forward without caramelization. If the heat is too high, the onions will brown unevenly and develop a bitter edge.
Add two tablespoons of butter to the skillet and stir to melt. Add the mushrooms and season with salt and pepper. Cook the mushrooms, stirring occasionally, for 5 to 6 minutes until the mushrooms are brown and tender.: When the butter melts, it should sizzle softly, signaling the right temperature to add the mushrooms. As they cook down, you will hear a steady gentle sizzle and see them release then reabsorb their moisture, concentrating flavor and producing a rich, savory aroma. Stirring occasionally helps them brown uniformly. A frequent misstep is overcrowding the pan, which causes steaming instead of browning, leaving the mushrooms bland and watery.
Stir in the garlic and continue cooking and stirring for another 1 to 2 minutes.: As the garlic hits the warm pan, it will perfume the mixture with a fragrant, savory note. You should smell its presence almost immediately, but watch closely because garlic can shift from fragrant to bitter quickly. Keep the heat moderate and stir constantly to avoid burning. If you notice a sharp, acrid smell, the garlic has begun to scorch and you should remove the pan from heat briefly to cool.
Add another 2 tablespoons of butter to the skillet and sprinkle the flour over the top. Stir the flour into the mushroom mixture and cook for 2 to 3 minutes, stirring frequently.: The butter and flour should combine into a paste that smells slightly toasted, which removes the raw flour taste. Stirring continuously ensures a smooth roux that will thicken without lumps. You will notice the mixture take on a pale, golden hue as it cooks. Common trouble is adding liquid too quickly or not stirring enough, which can create lumps; whisk gently if needed to smooth them out.
Slowly whisk in the chicken stock and half and half and bring mixture to a simmer, whisking often. Cook for 5 to 7 minutes or until sauce is thick and bubbly. Taste and season with salt and pepper if needed.: As you add the liquids, the pan will steam and the sauce will loosen, then gradually thicken as it reaches a gentle simmer. Whisking helps incorporate everything into a silky texture, and you should hear a low, steady bubbling as it cooks. The sauce is ready when it coats the back of a spoon and the aroma is rich and savory. If the sauce is thin, simmer a bit longer; if it becomes too thick, stir in a splash more stock. Over seasoning at this stage is a pitfall, so taste and adjust carefully.
Add green beans and stir until coated. Keep mixture in the oven safe skillet or transfer to a 3 quart baking dish and bake for 25 minutes.: When the green beans hit the sauce, you will notice a glossy coating and a mingling of aromas. The beans should be evenly distributed, each strand covered in the creamy mushroom sauce. Transfer to an oven safe dish so the heat can gently finish the melding of flavors. In the oven, you will hear a soft bubbling and see the edges begin to set. A mistake to avoid is packing the dish too tightly, which prevents even baking and can cause an undercooked center.
Remove from oven, top with fried onions and continue baking for another 5 to 10 minutes or until fried onions are golden.: After the initial bake, the casserole will be hot and bubbling; adding the fried onions and returning it to the oven crisps them to a beautiful golden brown. Watch closely in the final minutes, as the topping can go from perfect to overly dark quickly. The finished look is bubbling edges with a deeply toasted, crunchy topping. A common oversight is not letting the casserole rest for a few minutes before serving, which helps set the sauce slightly and makes serving cleaner.
Serve immediately and enjoy!: The final dish should present a warm, bubbling surface and a crunchy, golden top. Serve while still hot so the contrast between creamy sauce and crisp onions is at its peak. Letting it sit too long will soften the topping and dull the textures, so aim to plate soon after it comes out. If you must wait, briefly reheat in a hot oven to refresh the crunch.