Complex sentence: When Harun al-Rashid made his hajj in 186 AH, and intended to visit Madina, he sent his vizier Yahya ibn Khalid ibn Barmak ahead to locate a suitable guide, and Yahya chose al-Waqidi.
Split into simpler sentences: When Harun al-Rashid made his hajj in 186 AH, he visited Madina. He sent his vizier Yahya ibn Khalid ibn Barmak ahead to locate a suitable guide and Yahya chose al-Waqidi.