The correct option is D If I'd known you were going to be upset
Since the sentence implies an outcome that was undesirable, the rest of the sentence should express the condition that made the outcome unpleasant. Hence, Option D is correct. The rest of the options do not fit this description, hence, incorrect.