diff --git a/src/slurmctld/job_mgr.c b/src/slurmctld/job_mgr.c
index 04982cbb9e08a9fac283c8fc975f67138f9662d4..136052e8371c3015f3a5949365b83bab9697f97b 100644
--- a/src/slurmctld/job_mgr.c
+++ b/src/slurmctld/job_mgr.c
@@ -2264,6 +2264,16 @@ extern struct job_record *find_job_array_rec(uint32_t array_job_id,
 			}
 			job_ptr = job_ptr->job_array_next_t;
 		}
+		/* Look for job record with all of the pending tasks */
+		job_ptr = find_job_record(array_job_id);
+		if (job_ptr->array_recs && job_ptr->array_recs->task_id_bitmap){
+			inx = bit_size(job_ptr->array_recs->task_id_bitmap);
+			if ((array_task_id < inx) &&
+			    bit_test(job_ptr->array_recs->task_id_bitmap,
+				     array_task_id)) {
+				return job_ptr;
+			}
+		}
 		return NULL;	/* None found */
 	}
 }
diff --git a/src/slurmctld/job_scheduler.c b/src/slurmctld/job_scheduler.c
index c4aa640f8d585b8c6fb5a1af68bc198502de9de8..ee322385902e9568643f9aef244f4fc41062bc07 100644
--- a/src/slurmctld/job_scheduler.c
+++ b/src/slurmctld/job_scheduler.c
@@ -1889,8 +1889,7 @@ extern int test_job_dependency(struct job_record *job_ptr)
 	depend_iter = list_iterator_create(job_ptr->details->depend_list);
 	while ((dep_ptr = list_next(depend_iter))) {
 		bool clear_dep = false;
-		if (dep_ptr->array_task_id == INFINITE) {
-			/* Advance to latest element of this job array */
+		if (dep_ptr->array_task_id != NO_VAL) {
 			dep_ptr->job_ptr = find_job_array_rec(dep_ptr->job_id,
 							dep_ptr->array_task_id);
 		}