Get the status message string I tried to get the string messages and create a condition based on the string, but I don't know how to pull the string value.

This is an example of message.
You don't need to pull the string, you can use the markup object in a string comparision directly:

$markup = \Drupal\Core\Render\Markup::create('Test');

if ($markup == 'Test') {
  // the markup string is "Test"
}


When you want to use triple equals then you have to type cast the object to a string first:

if ((string) $markup === 'Test') {
  // the markup string is "Test"
}