Get the category is not working on url

I solved this problem using wp_get_object_terms, probably not the cleanest way but it does what I wanted.

For those of you having the same problem, this is how my final product looks:

function custom_permalink( $post_link, $id = 0, $leavename ) {
    global $wp_rewrite;

    $post = &get_post( $id );
    if ( is_wp_error( $post ) || $post->post_type != 'custom_list' )
        return $post_link;

    $term = wp_get_object_terms($post->ID, 'category'); 
    if(!empty($term)): 
        $parent = $term[0]->parent; 
        $parents[] = $term[0]->term_id;
        while ($parent): 
        $parents[] = $parent; 
        $new_parent = get_term_by( 'id', $parent, 'category' ); 
        $parent = $new_parent->parent; 
        endwhile; 
    endif;


    $newlink = $wp_rewrite->get_extra_permastruct( 'custom_list' );
    $newlink = str_replace( '%post_id%', $post->ID, $newlink );
    $newlink = str_replace( '%category%', $new_parent->slug.'-'.$term[0]->slug, $newlink );
    $newlink = home_url( $newlink );
  return $newlink;

  }
add_filter( 'post_type_link', 'custom_permalink', 1, 3 );

Hope this helps. Also if you know of a more efficient way to deal with my original post, please let me know.