Restrict subtasks creation when the parent is Done

Hello , I want to restrict subtask creation when the status of parent is done by displaying a message error when we try to click on the native icon of creating a subtask.So , I’ve created this function :

export async function preventSubtaskCreation(event, context) {
  const { issue } = event;

  if (issue?.fields?.issuetype?.subtask) {
    try {
      const parentIssueKey = issue?.fields?.parent?.key;
      if (!parentIssueKey) {
        return {
          statusCode: 400,
          body: 'Parent issue key is undefined or not found.',
        };
      }

      const response = await api.asApp().requestJira(route`/rest/api/3/issue/${parentIssueKey}`);
      if (!response.ok) {
        const errorMessage = await response.text();
        console.error('Error fetching parent issue status:', errorMessage);
        throw new Error('Failed to fetch parent issue status');
      }
      const parentData = await response.json();

      const parentStatus = parentData?.fields?.status?.name;

      if (parentStatus === "Done") {
        return {
          statusCode: 400,
          body: `Cannot create a subtask because the parent issue is in status "Done".`,
        };
      }

    } catch (error) {
      console.error(`Error in preventSubtaskCreationFunction: ${error}`);
      return {
        statusCode: 500,
        body: `An error occurred while checking the parent issue status: ${error.message}`,
      };
    }
  }

  return {
    statusCode: 200,
    body: 'Subtask creation allowed.'
  };
}

manifest.yml :

modules:
  jira:issuePanel:
    - key: subtask-panel
      title: Advanced Panel
      function: panelFunction
      icon: https://developer.atlassian.com/platform/forge/images/icons/issue-panel-icon.svg
  trigger:
    - key: prevent-subtask
      function: preventSubtaskCreation
      events:
        - avi:jira:created:issue 
  function:
    - key: panelFunction
      handler: index.panelFunction
    - key: preventSubtaskCreation
      handler: index.preventSubtaskCreation
permissions:
  scopes:
    - read:jira-user
    - read:jira-work
    - write:jira-work
    - manage:jira-project
    - storage:app
    - manage:jira-configuration

But the problem that the message error is not displayed in the interface , how can I resolve this ?