Line up green beans on a chopping board a few at a time. Cut off the tops and tails.
Bring a large pot of water to boil. Blanch green beans for 3 minutes. Remove with strainer and immediately place green beans in a cold bath to stop the cooking. Drain and transfer to a casserole dish. Mix in sliced mushrooms.
Melt butter over low heat in a saucepan. Sauté onion and garlic for 2 minutes until soft. Add flour and stir constantly until mixture starts to brown, about 3 minutes.
Stir in dried thyme. Gradually pour in milk whisking or stirring into a smooth bubbly sauce. Season with salt and pepper. Turn off stove.
Pour sauce over green beans and mushrooms.
Sprinkle cheese on the top. Bake in a preheated 350°F (180°C) oven for 25 minutes. Remove casserole from oven and sprinkle French onions on the top. Return to the oven and continue to bake for another 5 minutes.