Preheat the oven to 400°F. Heat the olive oil in a large skillet over medium heat. Add the onion, carrots, and celery and cook until softened, about 5 minutes.
Stir in the garlic and tomato paste and cook for 1 minute. Add the lentils, vegetable broth, thyme, salt, and pepper. Bring to a simmer and cook for 20 minutes until the lentils are tender and most of the liquid is absorbed.
Stir the frozen peas into the lentil mixture and remove the skillet from heat.
While the lentils cook, place the sweet potatoes in a large pot and cover with water. Boil until fork-tender, about 12 minutes. Drain and return to the pot.
Mash the sweet potatoes with the butter and milk until smooth. Season with salt and pepper.
Transfer the lentil filling to a baking dish. Spread the mashed sweet potatoes evenly over the top.
Bake for 20 minutes until the topping is lightly browned and the filling is bubbling at the edges.