Jobs get skipped when depending on an optional manual job

Summary

Jobs that depend on an optional manual job using needs, will be skipped even when optional: true is used.

Steps to reproduce

Create an optional manual job (when: manual and allow_failure: true) and a job that needs the manual job with optional: true. The last job will be skipped unless the manual job is triggered.

Expand for an example yml file
stages:
  - build
  - test_build
  - test_run
  - doc

.template: &build_linux_setup
  image: debian:buster
  tags:
    - docker
  script:
    - exit 0

build:
  <<: *build_linux_setup
  stage: build
  needs: []

test_build:
  <<: *build_linux_setup
  stage: test_build
  needs: []

test_run:
  <<: *build_linux_setup
  stage: test_run
  needs:
    - test_build
  when: manual
  allow_failure: true

doc:
  <<: *build_linux_setup
  stage: doc
  needs:
    - job: build
    - job: test_run
      optional: true

What is the current bug behaviour?

The job that needs the optional manual job is skipped

What is the expected correct behaviour?

The job that needs the optional manual job should run without pulling the artifacts form the manual job.

Edited by Ben Waumans