Preheat the oven to 350°F (180°C), or 160°C if using a fan oven. Butter a 9x13 dish and set aside.
In a large saute pan over medium heat, melt the butter and add the onion. Cook, stirring frequently, until the onions begin to soften, about 4-5 minutes. Add the garlic and cook for an additional minute, stirring constantly.
Add the flour, thyme, salt and pepper and cook, stirring constantly, for 2 minutes.
Slowly pour the chicken broth into the pan, whisking constantly to avoid clumps. Add the heavy cream and bring to a low simmer, stirring occasionally, until the sauce thickens. Remove from heat and set aside until needed.
Place half the sliced potatoes evenly spread in the bottom of the 9x13 pan. Add half of the sauce, the half of the ham and cheese. Add the remaining potatoes, followed by the remaining sauce and finally the remaining ham and cheese.
Tightly cover the dish with aluminum foil, then bake in the oven for 45 minutes. Remove the foil and bake for an additional 30-45 minutes, or until the sauce is bubbly and the potatoes are tender.
Allow to sit for 10 minutes before serving, sprinkle with fresh minced parsley if desired.