Start by bringing a large pot of salted water to a boil.
Add 2 tablespoons of the olive oil to a large deep skillet and bring to medium-high heat. Cook half the batch of sliced mushrooms until browned, about 12 minutes. Transfer the mushrooms to a bowl and fry the second batch in the skillet using the same method, with 2 tablespoons of olive oil.
Pour all the mushrooms back into the skillet and add the garlic, shallots, thyme, and salt. Cook for a few minutes, until the shallots are softened.
Add the flour to the mushrooms and cook for 2-3 minutes. Add the coconut milk and reduce heat to a low simmer. Add the spinach and lemon juice and cover with the lid to wilt the spinach. Keep the sauce on very low heat.
Cook the spaghetti according to the package instructions, until al dente. Scoop the pasta out of the pot and into the mushroom sauce with 2-3 tablespoons of pasta water to thin. Mix to combine. Transfer to bowls and serve.