Preheat the oven to 375 degrees F and grease a 13x9-inch pan with butter or nonstick cooking spray.
Add the olive oil to a large skillet set over medium heat. When the oil is warm, add the green beans and a pinch of salt.
Cook the beans for 5 minutes, or until they are just beginning to soften and turn bright green. Transfer the beans to the prepared baking dish.
In the same skillet, melt the butter over medium heat. Add the garlic and cook it for 1 minute, or until just fragrant. Then add the flour and whisk until it forms a paste. Continue to cook the roux for an additional minute.
Slowly add the chicken stock, whisking constantly as it's added. Whisk it until no lumps of roux remain. Add the heavy cream and whisk to combine.
Cook the sauce for 2-3 minutes, stirring often, or until it is thick and bubbling. Then add the cream cheese and stir until the cream cheese is fully melted.
Add the lemon juice, thyme, red pepper flakes, and nutmeg. Whisk to combine. Season with salt and pepper, to taste.
Pour the sauce over the green beans and gently toss to combine.
Bake the casserole for 10 minutes. Then sprinkle over the fried onions and bake for another 8-10 minutes, or until the onions are golden brown and the beans are just tender.
