Blanch beans 6 to 7 minutes in a large pot of well salted boiling water until bright green and just tender when bitten then shock in ice water to lock color and stop cooking. Drain very well and pat dry to avoid watering down the sauce.
Brown mushrooms: heat butter and oil over medium high in a wide skillet. Sauté mushrooms and onion with a pinch of salt until mushrooms give off liquid and edges brown, 8 to 10 minutes. Add garlic for 30 seconds until fragrant.
Make the sauce: sprinkle flour over vegetables and stir 1 minute to cook the raw taste. Whisk in stock slowly then half and half, Dijon, soy or Worcestershire, pepper and 0.5 teaspoon salt. Simmer 3 to 5 minutes to a spoon coating nappe consistency.
Combine and pan test: fold dried beans into sauce. Taste and adjust salt and acid. Mixture should be glossy and cling to beans without pooling.
Bake: preheat oven to 375 F. Transfer mixture to a 3 quart casserole. Sprinkle Parmesan if using. Bake uncovered 20 minutes until bubbling at edges and lightly browned.
Top and finish: scatter fried shallots or onions over the surface and bake 5 minutes more to set the topping. Serve after a 10 minute rest so the sauce thickens and scoops cleanly.