Prepare the casserole: Preheat the oven to 350 degrees F. Bring a large pot of salted water to a boil. Add the green beans and pearl onions and cook until the beans are bright green, 2 to 3 minutes. Drain the vegetables, then plunge into an ice bath to stop the cooking. Drain, then remove the skins from the pearl onions.
Combine the olive oil and butter in a large skillet over medium heat. Add the garlic and shallot and cook, stirring, until the shallot is caramelized, about 5 minutes. Add the bay leaves, then the mushrooms. Stir to combine, then add the thyme and season with salt and pepper. Sprinkle the mixture with the flour to tighten it up. Add the milk and boil 3 minutes to thicken; remove the bay leaves.
Place the green beans and pearl onions in a 3-quart casserole dish. Pour the "mushroom soup" over the vegetables and toss to make sure they are well coated. Transfer to the oven and bake 30 minutes.
Make the topping: Heat about 2 inches of vegetable oil in a large pot or Dutch oven until a deep-fry thermometer registers 360 degrees F. Toss the shallots in a bowl with enough flour to lightly coat. Working in batches, fry the shallots until golden brown and crisp, about 3 minutes. Using a slotted spoon, remove to paper towels to drain; season lightly with salt. Scatter over the casserole before serving.
Photograph by Kana Okada
Recipe courtesy of Tyler Florence for Food Network Magazine