I know this was weird before you made changes, but this could be refactored to be a little more readable.  Perhaps as follows:

```scala
private def search(cmd: String, id: String): Traversable[AppDefinition] = {
  val cmdPrefix = cmd.toLowerCase
  val idPrefix = id.toLowerCase

  /** Returns true iff `a` is a prefix of `b`, case-insensitively */
  def isPrefix(a: String, b: String): Boolean =
    b.toLowerCase contains a.toLowerCase

  service.listApps().filterNot { app =>
    val appMatchesCmd = cmd != null && cmd.nonEmpty && isPrefix(cmd, app.cmd)
    val appMatchesId = id != null && id.nonEmpty && isPrefix(id, app.id)
    appMatchesCmd || appMatchesId
  }
}
```