Preheat oven to 350°F. Spray a 9×13-inch baking dish with nonstick spray.
In a large bowl, combine the potatoes, butter, shredded cheese, and sour cream. Mix well and set aside.
In a medium, non-stick skillet over medium heat, melt butter.
Add onions and cook until softened (3-5 minutes). Add the garlic and cook for one more minute.
Add flour, salt, pepper, cayenne pepper, and dry mustard. Cook another minute.
Slowly add milk and chicken broth, whisking until well combined. Continue to cook, whisking until thickened.
Pour the sauce into the potato mixture. Mix well. Then, pour into the prepared baking dish.
Bake 45-50 minutes, until the casserole is bubbly and heated through.
While the casserole is baking, prepare the fried onions.
Line a large baking sheet with two layers of paper towels. Set aside.
To a large saucepan over high heat, add oil. Heat to 350°F.
Working in batches, add about 1 cup of onions to the hot oil. Fry, stirring occasionally, until onions turn pale golden brown, about 2-5 minutes. Using a fine mesh strainer or slotted spoon, carefully remove the fried onions from the hot oil. Place them in an even layer onto the lined baking sheet. Set aside and repeat with the remaining onions. (Make sure the oil is at 350°F before frying each batch.)
Sprinkle fried onions with salt, tossing to coat.
After the casserole has baked for 45-50 minutes, remove from the oven. Sprinkle the fried onions evenly over the top of the hot casserole.
Serve.