Others may have ideas of how you can get it directly through Powershell or by some other method. However, access review is optimal in terms of that's what it is designed for and in terms of monitoring access to specific applications it provides more granular management and better oversight. Adam is right here. The P2 licence is $9 per month US so this is a worthwhile investment to show what applications (including Teams) users are using, it identifies training needs quicker, distinguishes if someone has access to an application they shouldn't. It only needs to be given to the user who is performing the work.
When do you consider a user inactive? When the user account is disabled or after x number of days without a sign-in? I can see that the price for P2 licenses can be high just for this function but you might find other features together with this worth the price.
Checking if the user is active with Get-MailboxStatistics is unreliable and also requires a user to have a mailbox.