Preheat the oven to 425°F (218°C).
On a sheet of parchment paper cut to fit a rimmed baking sheet, roll the puff pastry sheet into a 10-by-10-inch square, gently smoothing out any creases in the pastry. Using a sharp knife, lightly score the pastry, leaving a 1-inch border all along the outer edge and being careful not to cut all the way through the pastry. Carefully slide the parchment with the scored pastry onto a rimmed baking sheet and refrigerate while you prepare the topping.
In a large skillet over medium heat, melt the butter. When it bubbles, toss in the garlic and thyme and cook for 1 minute. Add the leeks and cook until they begin to soften. Add the mushrooms and cook until they’re soft but not yet releasing any liquid. Dump the mushroom filling in a strainer situated over a bowl and let drain for a few minutes.
Spoon the mushroom filling onto the pastry, being careful to stay inside the scored lines. Either reserve the strained mushroom liquid for making vegetable stock or discard. Grind fresh black pepper, if using, over the topping.
Bake the tart for 15 minutes, checking the puff pastry after 10 minutes. If the pastry is already golden brown, cover the exposed pastry edges with foil strips to prevent it from turning too brown. After the 15 minutes, remove the tart from the oven and sprinkle it with the cheese. Bake for 5 to 7 minutes more, or until the cheese has melted and the pastry is golden brown. Again, it may be necessary to cover the outer edges with foil. Let cool 5 minutes and then slice into squares or rectangles. This tart is best eaten as soon as it is cool enough to handle. (Any leftover mushroom leek tart can be wrapped and refrigerated, but the pastry will suffer. To reheat, pop under the broiler for a few minutes. Whatever you do, don’t reheat the tart in the microwave.)