PREHEAT oven to 400°F.
HEAT oil in a skillet over medium heat. Add onions and cook until softened and lightly browned, 6-8 minutes. Add garlic and stir for 30 seconds until fragrant.
DRAIN cashews and add to a blender along with the rest of the sauce ingredients. Blend until smooth and pour into a large mixing bowl.
PEEL and thinly slice sweet potatoes and add to the bowl with the sauce. Make sure each slice gets coated with some sauce.
PLACE ⅓ of the sweet potato slices into an 8x6-inch baking dish, covering the bottom. Sprinkle half the onions on top. Layer another ⅓ of the sweet potatoes over and sprinkle the remaining onions on. Layer the remaining sweet potatoes on top. Pour the sauce evenly over.
COVER the dish with foil and bake for about 30-40 minutes until the sweet potatoes are just tender. Use a spoon to gently push down on the potatoes so the top gets some sauce on it.
UNCOVER and continue baking another 10 minutes or until the top is golden brown and the sauce has thickened.
COOL the dish on the counter for about 10 minutes to let the sauce thicken more.
GARNISH with fresh thyme leaves or chopped parsley, if desired.