Cover the potatoes with cold salted water, bring to a boil and simmer until very tender, about 15 minutes. Drain, return to the pot to dry for a minute, then mash with the butter and warm milk. Season well with salt and pepper.
Meanwhile, heat the olive oil in a large deep skillet over medium heat. Cook the onion, carrots and celery with a pinch of salt until softened, about 8 minutes. Add the mushrooms and cook until their liquid evaporates, 5–6 minutes.
Stir in the garlic, tomato paste and flour and cook for 1 minute. Add the lentils, broth, soy sauce and thyme. Bring to a boil, then cover and simmer for 25–30 minutes, stirring occasionally, until the lentils are tender and the sauce is thick.
Heat the oven to 400°F (200°C). Stir the peas into the filling and season to taste. Spread the filling in a 9x13-inch baking dish or 3-quart casserole.
Spoon the mashed potatoes over the top and spread to the edges. Rough up the surface with a fork so it browns in ridges.
Bake for 20–25 minutes until bubbling at the edges and golden on top. Rest 10 minutes before serving.