Preheat oven to 350 degrees. Grease a 9 x 13 pan and set aside.
Cook onion and butter over medium low until onion is tender. Add thyme and flour and cook for another 2-3 minutes.
Turn heat to low and add milk a little bit at a time whisking between each addition. The mixture will thicken but as you continue adding and whisking it will smooth out. Stir in chicken broth, salt, and pepper bring to a boil and allow to boil for 1 minute.
Place 1/3 of the potatoes topped with 1/3 of ham and 1/3 of the sauce. Repeat layers ending with sauce on top.
Bake covered for 50 minutes. Uncover and bake an additional 25-35 minutes longer or until potatoes are tender. Add the cheese the last 15 minutes.
Cool at least 15 minutes before serving. Garnish with parsley.