Preheat the oven to 375°F. Lightly butter or spray a 9-by-13-inch baking dish.
butter
Bring a large pot of water to a boil and add a generous handful of salt. Add the green beans and cook until bright green and beginning to soften but still firm in the center, about 5 minutes. Immediately transfer them to an ice bath. Once cold, drain and dry them thoroughly.
kosher salt, 2 pounds fresh green beans
Heat 2 tablespoons of reserved shallot oil (from the fried shallots, or plain vegetable oil if using store-bought fried onions) and 2 tablespoons of butter in a large, wide skillet over medium-high heat. Add the mushrooms in an even layer. Cook without stirring until browned underneath, about 2 minutes. Continue cooking, stirring occasionally, until their moisture evaporates and they are well browned, about 5 minutes longer. Transfer to a plate, then reduce the heat to medium.
2 tablespoons oil, 5 tablespoons unsalted butter, 1 pound cremini mushrooms
Melt the remaining 3 tablespoons butter, then add the chopped shallot and cook until soft and translucent, about 3-4 minutes. Add the garlic, thyme, and nutmeg, then cook until the garlic is fragrant, about 30 seconds.
1 shallot, 2 garlic cloves, 1 teaspoon fresh thyme leaves, ⅛ teaspoon nutmeg
Sprinkle in the flour and cook, stirring constantly, until it completely coats the shallots and loses its raw appearance, about 1-2 minutes. Slowly whisk in the chicken stock, followed by the heavy cream. Bring to a gentle simmer and cook until the sauce is smooth and thick enough to coat the back of a spoon, about 5-7 minutes.
¼ cup all-purpose flour, 2 cups low-sodium chicken stock, 1 cup heavy cream
Stir in the soy sauce, sherry vinegar and black pepper along with the reserved mushrooms. Taste and add additional salt and pepper as needed.
2 teaspoons soy sauce, 2 teaspoons sherry vinegar, ½ teaspoon black pepper
Fold the green beans into the mushroom sauce until evenly coated. Transfer everything to the prepared baking dish and spread it into an even layer.
Bake uncovered until the sauce is bubbling around the edges and the green beans are tender, about 20-25 minutes. Top with the fried shallots and bake for another 5 minutes until they’re hot and crisp.
Let the casserole rest for 5 minutes before serving.