<% political_membership = role_appointment.historical_account.try(:political_membership) %>
<%= content_tag_for :div, role_appointment, class: 'govuk-grid-column-one-quarter', role: "listitem" do %>
  <%= render "govuk_publishing_components/components/image_card", {
    href: historic_appointment_path(role.historic_param, role_appointment.person),
    image_src: role_appointment.person.image_url(:s216),
    image_loading: "lazy",
    heading_text: role_appointment.person.name,
    extra_links: previous_dates_in_office_prime(role, role_appointment.person, political_membership),
    extra_links_no_indent: true
  } %>
<% end %>

<% political_membership = role_appointment.historical_account.try(:political_membership) %>
  <%= content_tag_for :div, role_appointment, class: 'govuk-grid-column-one-quarter', role: "listitem" do %>
    <%# Content for "theresa-may' does not exist at present, temporary check to remove link %>
    <% if historic_appointment_path(role.historic_param, role_appointment.person) != "/government/history/past-prime-ministers/theresa-may" %> 
      <%= render "govuk_publishing_components/components/image_card", {
        href: historic_appointment_path(role.historic_param, role_appointment.person),
        image_src: role_appointment.person.image_url(:s216),
        image_loading: "lazy",
        heading_text: role_appointment.person.name,
        extra_links: previous_dates_in_office_prime(role, role_appointment.person, political_membership),
        extra_links_no_indent: true
      } %>
    <% else %>
      <%= render "govuk_publishing_components/components/image_card", {
        image_src: role_appointment.person.image_url(:s216),
        image_loading: "lazy",
        heading_text: role_appointment.person.name,
        extra_links: previous_dates_in_office_prime(role, role_appointment.person, political_membership),
        extra_links_no_indent: true
      } %>
    <% end %>
<% end %>

Remove "theresa-may" - Past Prime Ministers
Remove "theresa-may"  - Past Prime Ministers

Content does not exist - removing