| INCOME TAXES - Summary of Income Tax Contingencies (Details) - USD ($) $ in Thousands | 12 Months Ended | ||
|---|---|---|---|
| Jun. 30, 2023 | Jun. 30, 2022 | Jun. 30, 2021 | |
| Reconciliation of Unrecognized Tax Benefits, Excluding Amounts Pertaining to Examined Tax Returns | |||
| Unrecognized tax benefits at the beginning of the year | $ 217,927 | $ 149,642 | $ 172,443 | 
| Increases for tax positions taken in current year | 44,590 | 49,311 | 31,113 | 
| Increases for tax positions taken in prior years | 434 | 20,917 | 6,557 | 
| Decreases for settlements with taxing authorities | (45,042) | 0 | (28,651) | 
| Decreases for tax positions taken in prior years | (3,929) | (267) | (19,360) | 
| Decreases for lapsing of statutes of limitations | (888) | (1,676) | (12,460) | 
| Unrecognized tax benefits at the end of the year | $ 213,092 | $ 217,927 | $ 149,642 | 
| X | ||||||||||
| 
- Definition A roll forward is a reconciliation of a concept from the beginning of a period to the end of a period. No definition available. 
 | 
| X | ||||||||||
| 
- Definition Amount of unrecognized tax benefits. Reference 1: http://www.xbrl.org/2003/role/disclosureRef 
 | 
| X | ||||||||||
| 
- Definition Amount of decrease in unrecognized tax benefits resulting from tax positions taken in prior period tax returns. Reference 1: http://www.xbrl.org/2003/role/disclosureRef 
 | 
| X | ||||||||||
| 
- Definition Amount of decrease in unrecognized tax benefits resulting from settlements with taxing authorities. Reference 1: http://www.xbrl.org/2003/role/disclosureRef 
 | 
| X | ||||||||||
| 
- Definition Amount of increase in unrecognized tax benefits resulting from tax positions that have been or will be taken in current period tax return. Reference 1: http://www.xbrl.org/2003/role/disclosureRef 
 | 
| X | ||||||||||
| 
- Definition Amount of increase in unrecognized tax benefits resulting from tax positions taken in prior period tax returns. Reference 1: http://www.xbrl.org/2003/role/disclosureRef 
 | 
| X | ||||||||||
| 
- Definition Amount of decrease in unrecognized tax benefits resulting from lapses of applicable statutes of limitations. Reference 1: http://www.xbrl.org/2003/role/disclosureRef 
 |