Heat the oven: Preheat to 375°F. Grease two 9x13-inch baking dishes.
Prep the beans: Bring a large pot of salted water to a boil.
Add green beans and cook 4–5 minutes, until crisp-tender and bright. Drain and plunge into ice water to stop cooking. Drain well.
Sauté the aromatics: In a large, heavy pot, heat olive oil and half the butter over medium-high.
Add onions and a pinch of salt. Cook 5–7 minutes, until soft and lightly golden.
Cook the mushrooms: Add mushrooms. Cook 7–10 minutes, stirring occasionally, until they release liquid and it evaporates.
Add remaining butter and the garlic; cook 1 minute until fragrant.
Make the roux: Sprinkle flour over the vegetables. Stir constantly for 1–2 minutes to cook the flour.
Build the sauce: Gradually whisk in warm broth, about 1 cup at a time, until smooth. Stir in half-and-half.
Add salt, pepper, onion powder, and nutmeg. Simmer 3–5 minutes, stirring, until thick enough to coat a spoon.
Add cheese (optional): Off the heat, stir in shredded cheese until melted for a richer sauce.
Combine: Fold the blanched beans into the sauce. Taste and adjust seasoning—this is your last chance to get it right.
It should be well-seasoned but not salty.
Assemble: Divide the mixture between the two prepared pans. Top each with about a third of the fried onions, reserving some for later.
Bake: Cover loosely with foil and bake 20 minutes. Remove foil, add remaining fried onions on top, and bake another 10–15 minutes, until bubbling and the onions are deep golden.
Rest and serve: Let stand 10 minutes before serving so it sets and serves cleanly.