Assuming it's level 32+. I don't think this would affect the results, but what about catching the Pokemon causing the level up vs gaining the exp prior to the capture, like if you leveled up in an SOS battle?
Edit: To clarify, you have an empty space in the party, and the level up happens in the same battle where you catch the Dark Type.
Asking about Gens 6-8.
To test this I took a pancham got it to the point where it would evolve with just a but of Xp and then caught a dark time with extra space in my party. The following is what happened in the order it happened.
Pancham gained Xp, Pancham leveled up.
Morgrem was added to your party.
Pancham did not evolve however.
Disclaimer This answer is for gen 8 only because I don’t have gens 6-7 so if this isn’t enough to answer your question I’ll turn this into a comment.
Source: Testing myself
If you leveled up Paschal then caught the dark type (assuming you have a space in your party) pancham wouldn't evolve. But if you caught a dark type and it was in your party THEN pancham leveled up, pancham would evolve.