It seems you are trying to implement Selective Wipe
and Retire
on Microsoft Intune
As you know both remove devices from Intune that are no longer needed
Difference
You cannot replace wipe
with Retire
because their functionality is not similar. I have described below as per official statement.
Selective Wipe
The Wipe action restores a device to its factory default settings. The user data is kept if you choose the Retain enrollment state and user account checkbox. Otherwise, all data, apps, and settings will be removed
Retire
The Retire action removes managed app data (where applicable), settings, and email profiles that were assigned by using Intune. The device is removed from Intune management. This happens the next time the device checks in and receives the remote Retire action
Retire leaves the user's personal data on the device.
Note:
Before you remove a user from Azure Active Directory (Azure AD), use
the Wipe or Retire actions for all devices that are associated with
that user. If you remove users that have managed devices from Azure
AD, Intune can no longer wipe or retire those devices.
For more details you could refer this official docs. If you still have any query feel free share. Thanks and happy coding!