Get the status message string
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"
}