Thaw the hashbrowns for at least 2 hours or overnight. Press with paper towels if they seem wet.
Preheat the oven to 350°F and spray a 9x13 baking dish with cooking spray.
In a large bowl, stir together the hashbrowns, cream of chicken soup, milk, cheddar cheese, sour cream, salt, pepper, and optional onion until evenly coated.
Spread the mixture into the prepared baking dish and press it into the corners.
Drizzle the melted butter evenly over the top. Add cornflakes if using.
Bake uncovered for 1 hour, until the edges are bubbling and the top is golden.
Let rest for 5 minutes before serving.
Notes
Thaw the hashbrowns before mixing so the casserole does not turn watery. Use two cans of condensed soup for a creamier texture. Drizzle the butter over the top instead of stirring it in. Bake uncovered so the top can turn golden.