Example How to get last content moderation state in drupal 8
// Check if we are viewing the default revision.
if ($entity->isDefaultRevision() == TRUE) {
$revision_ids = \Drupal::entityTypeManager()->getStorage('node')->revisionIds($entity);
//$current_revision_id = $node->getRevisionId();
// Check if the last item in the revisions is the loaded one.
$last_revision_id = end($revision_ids);
if ($entity->getRevisionId() != $last_revision_id) {
// Load the revision.
$last_revision = \Drupal::entityTypeManager()->getStorage('node')->loadRevision($last_revision_id);
// Get the revisions moderation state.
$last_revision_state = $last_revision->get('moderation_state')->getString();
}
}