@actions/github: How to filter out hidden comments?

I am making a Node.js script to run in GitHub Workflow to edit all comments made by github-actions[bot] in a pull request. I want to avoid editing comments that are hidden.


const { getOctokit, context } = require('@actions/github')
const github = getOctokit(process.env.GITHUB_TOKEN).rest
const allComments = await github.issues.listComments({
    issue_number: context.issue.number,
    owner: context.repo.owner,
    repo: context.repo.repo,
const editTargets = allComments
    .filter(comment => comment.user?.login === 'github-actions[bot]')

I need to replace NOT_HIDDEN with actual code.

For context, this is a hidden comment:

The hidden state doesn’t appear to be exposed in the REST API: Issues - GitHub Docs

It is in the GraphQL API, however (isMinimized and minimizeReason): Objects - GitHub Docs

From the toolkit repo:

You can also make GraphQL requests. See GitHub - octokit/graphql.js: GitHub GraphQL API client for browsers and Node for the API.

const result = await octokit.graphql(query, variables);
1 Like