Finally done with the case where a lesson has topics.

add_filter(
‘learndash_completion_redirect’,
function( $link, $post_id ) {

// We only want to do this for Lessons (sfwd-lessons).
if ( get_post_type( $post_id ) == ‘sfwd-lessons’ ) {
$course_id = learndash_get_course_id( $post_id );
$course_steps_object = LDLMS_Factory_Post::course_steps( $course_id );
$course_steps_object->load_steps();
$course_steps_l = $course_steps_object->get_steps( ‘l’ );
$current_step_idx = array_search( ‘sfwd-lessons:’ . $post_id, $course_steps_l );
if ( false !== $current_step_idx ) {
$next = array_slice($course_steps_l,$current_step_idx+1,count($course_steps_l),true );
$test = preg_grep(“/sfwd-lessons:/i”,$next);
//faster way in O(1) of getting the next lesson array id
$next_step_idx = array_search(array_pop(array_reverse($test)), $course_steps_l );
if ( isset( $course_steps_l[ $next_step_idx ] ) ) {
list( $next_step_idx, $next_step_id ) = explode( ‘:’, $course_steps_l[ $next_step_idx ] );
if ( ( ! empty( $next_step_idx ) ) && ( ! empty( $next_step_id ) ) ) {
$next_step_link = get_permalink( $next_step_id );
$link = $next_step_link;
}
}
}
}

// Always return $link
return $link;

},
20,
2
);

As you can see, not exactly default Learndash functionality but this will auto redirect user to next lesson (if there is one) when clicking complete lesson and will take into account any lesson topics so that when completing the last lesson topic and the lesson is auto completed it will take user to the next lesson automatically.