I finally, finally figured it out! I was not able to get the category id in the first place. Strangely, get_query_var(‘cat’) is not working. Here is the way that worked for me, in case someone else also struggles with this:
function my_new_category_order( $query ) {
$category = get_queried_object();
$cat_id = $category->term_id;
$post_order = get_term_meta($cat_id, 'post-order', true);
//Now everything works!
if ( $post_order =='oldest' && $query->is_category($cat_id) && $query->is_main_query() ) {
$query->set( 'order', 'ASC' );
}
}
add_action( 'pre_get_posts', 'my_new_category_order' );