Set a 6-quart or larger Instant Pot to sauté with the butter. Once melted, add the onion, mushrooms and garlic and cook until softened and just beginning to brown, about 3 to 5 minutes. Stir in the green beans, chicken broth and heavy cream. Lock the lid and make sure the valve is set to seal. Pressure cook on high for 10 minutes. Allow the pressure to naturally release for 5 minutes before manually releasing any residual pressure.
Carefully unlock the lid and set the pressure cooker to sauté. Add the cream cheese and stir until melted through. In a small bowl, combine the cornstarch with 2 tablespoons water. Stir it into the green bean casserole and cook until the sauce has thickened. Season with salt and pepper and the red pepper flakes, if using. Turn the pressure cooker off and serve warm with the crispy onions on top.
Tip: For a crunchy coating, you can transfer the mixture to a casserole dish, top with the crispy onions and place under the broiler until golden brown and bubbly.