Use a mandolin to slice potatoes into thin slices. Wash slices to remove excess starch then set aside to dry.
Melt the butter in a large pan at medium-high heat then sauté the onions and garlic until soft and fragrant.
Add in the flour and mix to coat the sautéed onions and dissolve into the butter. Cook for 1 minute.
Turn the pan heat down to a medium temperature. Slowly add in the milk and whisk to combine ingredients until the roux thickens.
Mix to combine the mustard, thyme, salt, and pepper with the roux. Set pan heat down to the lowest temperature and cover with a lid for later use. Preheat the oven to 400 degrees.
Grease a deep cast-iron skillet with cooking spray and evenly layer the bottom with ¼ of sliced potatoes, ¼ of ham cubes, ¼ of roux, and ¼ of shredded cheddar. Repeat until 4 times until the potatoes, ham, roux, and cheddar are no more.
Top the dish with bacon then cover to seal the cast-iron skillet with aluminum foil. Bake in the oven for 1 hour.
After the dish has cooked for 1 hour, remove the skillet from the oven and turn on the broiler. Once the broiler is ready, remove the foil and transfer the skillet to the broiler to cook for 10-12 minutes until the cheese is golden brown.
Remove the skillet from the broiler and let cool for 10 minutes then serve.