Blanch the green beans and pearl onions by placing them into a large pot of rapidly boiling water. Cook them for 2 minutes, until the green beans brighten in color.
Remove the vegetables from the boiling water, then plunge in ice water to stop the cooking process.
Drain them, then remove the skins from the onions and set aside.
Coat a skillet with olive oil and butter. Over medium heat, cook the shallot and garlic down until caramelized. Add bay leaves, then the mushrooms; stir to combine. Season with salt, pepper, and thyme and then sprinkle the mixture with flour.
Add the milk a little at a time and boil for 3 minutes to thicken.
Place green beans and onions in a 2-quart casserole dish. pour mushroom mixture over the green beans; toss to make sure well coated.
Bake in preheated 350°F oven for 30 minutes. Top with fried onions and bake 10 minutes more.