Preheat the oven to 425°F (218°C). Adjust the oven rack to the middle position and lightly butter an 8-inch (20-cm) square or an 11-by-7-inch (28-by-18-cm) baking dish.
In a Dutch oven over medium-high heat, melt the butter. Add the onion and cook until softened, 5 to 7 minutes.
Stir in the thyme, garlic, salt, and pepper and cook until fragrant, about 30 seconds. Add the potatoes, stock, cream, and bay leaves and bring to a simmer.
Cover and reduce the heat to medium-low. Simmer until the potatoes are almost tender, 7 to 12 minutes. The potatoes are ready when the tip of a paring knife can easily be slipped into a slice with just a little resistance. Don’t overcook the potatoes or you’ll end up with mushy scalloped potatoes.
Discard the bay leaves and carefully transfer that luscious potato and cream mixture to the buttered baking dish. Use the back of a spoon to gently press the potato slices into a fairly even layer. (You can cover and refrigerate the scalloped potatoes for up to 24 hours.)
Sprinkle with the Cheddar and bake until the sauce is bubbling, the edges of the potatoes are crisp, and the top is golden brown, 10 to 15 minutes. (If the scalloped potatoes were refrigerated, cover the dish tightly with buttered aluminum foil and bake in a 400°F (200°C) oven until warm throughout, 25 to 45 minutes. Uncover, top with the Cheddar, and continue to bake uncovered until the Cheddar is lightly browned, about 20 minutes.)
Let the casserole cool for 10 minutes before scooping into it with a spoon and heaping creamy cheesy potato goodness onto plates.