Preheat the oven to 400°F and grease a 9×13-inch casserole dish.
Use a mandolin to slice the sweet potatoes into uniform rounds. Aim for a thickness of 1.3mm or 2mm. Set aside.
In a large skillet over medium-high heat, melt butter. Add minced onion and ¼ teaspoon salt. Sauté for 3-4 minutes, then add minced garlic and sauté until fragrant, about 1 minute.
Add flour, pepper, and fresh thyme to the skillet, stirring until it forms a paste. Cook for at least 1 minute.
Reduce heat to medium and slowly whisk in milk, ensuring it doesn't burn. Once added, the mixture should thicken quickly.
Slowly add chicken broth, whisking constantly to combine and thicken.
Remove from heat and gradually add parmesan and gruyere cheese, whisking until melted and smooth.
Spread 1 cup of cheese sauce evenly on the bottom of the casserole dish. Arrange sweet potato rounds, skin side up, filling the dish.
Pour remaining sauce over the potatoes, pushing it down between the slices.
Sprinkle Ritz cracker crumbs over the top, covering the dish.
Bake covered for 30 minutes, then uncovered for 30 minutes.
Let rest for 10 minutes before serving, garnishing with fresh thyme.