Unable to Delete the USA Region in Jira Align
Summary
Administrators experience difficulties when trying to delete the USA Region from Administration > Region in Jira Align, encountering an error message stating that some regions cannot be deleted due to existing relationships with users or Flexible Holidays. This error occurs even if Time Tracking is disabled or the Jira Align instance lacks a Time Tracking license.
Environment
Jira Align
Diagnosis
You are unable to Delete the USA Region from Administration > Region. The following error is seen when you try to delete the Region:
Some of the Regions cannot be deleted. Please remove all relationships to users and/or Flexible Holidays before deleting a Region.
You see the above error when you Delete the USA Region even in an instance where the Time Tracking is disabled or the instance does not have a Time Tracking license. All the Users and Flexible Holidays or Holiday Calendars associated with the Region need to be deleted before deleting the Region, but without Time Tracking, Flexible Holidays settings are not available in the UI.
Cause
The issue arises because, by default, Jira Align assigns the USA Region to certain users when an instance is created. Even without a Time Tracking license, these default users are associated with a holidayRegionId. This association prevents the deletion of the USA Region until these connections are removed or modified.
Solution
It's possible to use Jira Align API to resolve the issue if Time Tracking is not enabled:
1. Fetch user details associated with the USA Region in terminal using the provided API call:
curl -X GET "https://<site-name>.jiraalign.com/rest/align/api/2/users?$filter=regionId%20eq%20<holidayRegionId>%20or%20holidayRegionId%20eq%20<holidayRegionId>" -H "accept: application/json;odata.metadata=minimal;odata.streaming=true" -H "Authorization: bearer <API 2.0 Token>"
2. Update the user's `regionId` and `holidayRegionId` using the PATCH API call:
curl -X PATCH "https://<site-name>.jiraalign.com/rest/align/api/2/Users/<UID>" -H "accept: */*" -H "Authorization: bearer <API 2.0 Token>" -H "Content-Type: application/json;odata.metadata=minimal;odata.streaming=true" -d "{ \"value\": null, \"path\": \"holidayRegionId\", \"op\": \"replace\" }"
3. After updating the `regionId` and `holidayRegionId` for all affected users, try deleting the USA Region again from the Administration > Region interface.
Please note that the placeholders `<site-name>`, `<holidayRegionId>`, `<API 2.0 Token>`, and `<UID>` should be replaced with actual values for your specific Jira Align instance when making the API calls.