My suggestion is to purge the M job after it is really finished on the target server.
First, It does not make sense - the M job is removed before it is actually finished. I understand that the job is still trackable through the tracking file but we should be able to qstat both the M job and the job on the target server during the whole job life cycle. For example, we implemented a web application that informs users about their jobs and it uses the API, but it is better for us to ignore M jobs at all because we can not rely on the M job being in the system.
Second, there is a bug with dependency: Knowing the job is still running, you should be able to add a new dependent job with -W depend=afterok:<moved jobid>. If you try to add this dependency after job_history_duration, the <moved jobid> is purged and the <moved jobid> is unknown to the dependency.
There is an imperfection in this solution, which is that the M job is not stored with job_history_enable = False. I think we should keep the M jobs to be a part of the history. I am not sure how to deal with it.
Please, provide your comments.