Without knowing more from your post, my guess is that these inactive users in AD still have profiles in Office 365 and assigned licenses. So you need to delete these users, free their licenses (happens upon deletion), and await the 30 day grace period. Within those 30 days, you can fully restore these deleted users and their content. So these inactive users can still show up in search results during this grace period. After the 30 days and the following crawl – your problem will be permanently resolved.
If a user no longer needs licenses, like when an employee leaves an organization, you can delete that user’s account. When you do this, any licenses that were assigned to that person become available to assign to another user.
IMPORTANT When you delete a user account, it becomes inactive. During this inactive period, you have up to 30 days to fully restore the account. After 30 days, all data for that user is permanently deleted—except documents saved on SharePoint Online. Delete users only if you are certain that they won’t need this data in the future.
To delete the account for one or more users
Sign in to Office 365 with your work or school account.
Go to the Office 365 admin center.
Select Users > Active Users (or Users & groups > Add users, reset passwords, and more).
Select the name of the user or multiple users that you want to delete, and then click Delete.
- In the confirmation box, click yes.
Reference: Assign or unassign licenses for Office 365 for business - Delete a user account to free a license