Conditions 'translated' into groovy script

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager

// Get the current user
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
// Get the changed field
def exampleField = getFieldById(getFieldChanged())

if (currentUser == underlyingIssue.reporterUser && currentUser == underlyingIssue.assignee) { // <1>
    exampleField.setHidden(true)
} else {
    exampleField.setHidden(false)
}

if (ComponentAccessor.getGroupManager().getGroupsForUser(currentUser)?.find { it.name == "jira-administrators" }) { // <2>
    exampleField.setAllowInlineEdit(true)
} else {
    exampleField.setAllowInlineEdit(false)
}

def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def devProjectRole = projectRoleManager.getProjectRole("Developers")
if (currentUser.key == "luke" || projectRoleManager.isUserInProjectRole(currentUser, devProjectRole, underlyingIssue.getProjectObject())) { // <3>
    exampleField.setError("You are either Luke or you belong to Developers project role and you cannot edit the field")
    exampleField.setReadOnly(true)
} else {
    exampleField.clearError()
    exampleField.setReadOnly(false)
}

if (currentUser == underlyingIssue.projectObject.getProjectLead()) { // <4>
    exampleField.setDescription("Current User is project lead")
} else {
    exampleField.clearHelpText()
}

def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Multi User Picker CF")
if (currentUser == underlyingIssue.getCustomFieldValue(cf) || currentUser in underlyingIssue.getCustomFieldValue(cf)) { // <5>
    getFieldById("description").setFormValue("Current user is member of the Multi User Picker custom field")
} else {
    getFieldById("description").setFormValue("Current user is not member of the Multi User Picker custom field")
}

def cf2 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Single Group Picker CF")
def groupsToCompare = underlyingIssue.getCustomFieldValue(cf2) as ArrayList
if (ComponentAccessor.getGroupManager().getGroupsForUser(currentUser.key)?.disjoint(groupsToCompare)) { // <6>
    exampleField.setRequired(true)
} else {
    exampleField.setRequired(false)
}

if (getActionName() == "Start Progress" || getDestinationStepName() == "Done") { // <7>
    exampleField.setRequired(true)
} else {
    exampleField.setRequired(false)
}

Line 9: If current user is reporter AND current user is current assignee make the changed field hidden, else shown

Line 15: If current user in group 'jira-administrators' allow the inline edit of the changed field

Line 23: If current user is 'luke' or current user in project role 'Developers' make the changed field read-only and show an error message, else clear the error and make the field editable again

Line 31:  If current user is Project Lead add a description at the changed field, else clear the description

Line 38: If current user in user custom field value add a default value in the description

Line 46: If current user in group custom field value then make the changed field required, else optional.

Line 52: If workflow Action is 'Start Progress' or workflow Step is 'In Progress' then make the changed field required, else optional.