Set your oven to 350°F and grease a 9×13-inch casserole dish with nonstick spray.
In a large mixing bowl, stir together thawed hash browns, melted butter, shredded cheddar, and sour cream until well combined.
Heat 1/4 cup butter in a medium skillet over medium heat until melted.
Add the diced onion and cook until it softens, about 3 to 5 minutes, then stir in the minced garlic and cook for an additional minute.
Sprinkle in the flour, salt, black pepper, cayenne, and dried mustard, stirring for another minute to cook the flour.
Gradually whisk in the milk and chicken broth, keep whisking until the sauce thickens.
Pour this creamy sauce into the potato mixture and mix everything thoroughly before transferring it to the prepared baking dish.
Bake in the preheated oven for 45 to 50 minutes until the casserole bubbles and is heated through.
While baking, prepare a baking sheet with two layers of paper towels to drain fried onions.
Heat vegetable oil in a large saucepan to 350°F over high heat.
Fry the sliced onions in batches by adding about 1 cup of onions to the hot oil. Stir occasionally, cooking for 2 to 5 minutes until they turn golden and crisp.
Remove the fried onions with a slotted spoon or fine mesh strainer and spread them evenly on the paper towels. Repeat for all onion batches, maintaining oil temperature.
Sprinkle the fried onions with kosher salt and toss gently to coat.
Once the potato casserole is done baking, take it out of the oven and evenly cover the top with the freshly fried onions.
Serve the casserole hot and enjoy a comforting family favorite.