Preheat an oven to 375°F. Butter a 9-inch baking dish. In a 4-quart saucepan over medium-high heat, pour in oil to a depth of 1 inch and heat to 350°F on a deep-frying thermometer. Line a baking sheet with paper towels.
Put 1/3 cup of the flour in a small bowl and season with salt, black pepper and cayenne. Add the sliced shallots and toss to coat evenly. Working in batches, fry the shallots until golden brown and lightly crisped, 5 to 6 minutes. Transfer to the prepared baking sheet and lightly season with salt. Set aside.
In a large sauté pan over medium-high heat, warm the tablespoon oil and melt the tablespoon of butter. Add the mushrooms and cook, stirring occasionally, until well browned, 6 to 8 minutes. Reduce the heat to medium, add the chopped shallots and cook, stirring occasionally, until softened, 2 to 3 minutes. Add the remaining flour and cook, stirring constantly, until fragrant, about 1 minute. While stirring constantly, slowly add the stock and then the cream. Bring to a simmer and cook, stirring occasionally, until thickened, 3 to 4 minutes. Add the green beans and season with salt and black pepper. Transfer to the prepared baking dish and sprinkle the fried shallot rings on top.
Transfer to the oven and bake until the edges are bubbling and the top is browned, about 25 minutes. Let rest for 5 to 10 minutes before serving. Serves 8.