Heat oven to 375°F. Grease a 9×13-inch baking dish and set aside.
Boil spaghetti in well-salted water until just shy of al dente. Drain and set aside.
Warm olive oil and 1 tbsp butter in a large skillet over medium-high heat. Sauté mushrooms until browned, 5–6 minutes.
Stir in onion and cook until translucent, 3–4 minutes. Add garlic and thyme; cook 30 seconds.
Reduce heat to medium. Melt in remaining 3 tbsp butter. Sprinkle flour over vegetables and cook, stirring, 1 minute.
Slowly whisk in chicken broth, then half-and-half. Simmer, stirring, until lightly thickened, 3–5 minutes.
Off heat, stir in 3/4 cup Parmesan, salt, pepper, and lemon juice until smooth.
Combine sauce with cooked spaghetti, ham, peas, and parsley in a large bowl. Toss to coat evenly.
Pour mixture into the baking dish. Mix panko with melted butter and remaining 1/4 cup Parmesan; sprinkle over top.
Bake until bubbling and golden, 18–22 minutes. Rest 5 minutes before serving.