The correct answer is B: would have come. This sentence is an example of the third conditional, which is used to talk about hypothetical situations in the past and their hypothetical results. It describes something that did not happen and its imagined consequence. The structure of the third conditional is typically: If + past perfect (had + past participle), would have + past participle.
In the given sentence, "if they had been invited" is the 'if-clause' using the past perfect tense. Therefore, the main clause requires "would have" followed by the past participle of the verb, which is "come" (come, came, come). So, "would have come" correctly completes the sentence, indicating a past hypothetical action that did not occur because the condition (being invited) was not met. Options A ("would come") is for the second conditional, C ("will come") is for the first conditional, and D ("came") is simple past, none of which fit the structure or meaning of a past hypothetical situation.